evergreen 0.1

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 (110) hide show
  1. data/README.rdoc +4 -0
  2. data/bin/evergreen +18 -0
  3. data/lib/evergreen.rb +44 -0
  4. data/lib/evergreen/cli.rb +23 -0
  5. data/lib/evergreen/evergreen.js +3 -0
  6. data/lib/evergreen/runner.rb +56 -0
  7. data/lib/evergreen/server.rb +31 -0
  8. data/lib/evergreen/spec.rb +60 -0
  9. data/lib/evergreen/version.rb +3 -0
  10. data/lib/evergreen/views/list.erb +6 -0
  11. data/lib/evergreen/views/spec.erb +37 -0
  12. data/lib/jasmine/MIT.LICENSE +20 -0
  13. data/lib/jasmine/README.markdown +489 -0
  14. data/lib/jasmine/Rakefile +146 -0
  15. data/lib/jasmine/cruise_config.rb +21 -0
  16. data/lib/jasmine/doc/files.html +460 -0
  17. data/lib/jasmine/doc/index.html +322 -0
  18. data/lib/jasmine/doc/symbols/_global_.html +918 -0
  19. data/lib/jasmine/doc/symbols/jasmine.Block.html +417 -0
  20. data/lib/jasmine/doc/symbols/jasmine.Clock.html +678 -0
  21. data/lib/jasmine/doc/symbols/jasmine.Env.html +1169 -0
  22. data/lib/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
  23. data/lib/jasmine/doc/symbols/jasmine.Matchers.html +1474 -0
  24. data/lib/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
  25. data/lib/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
  26. data/lib/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
  27. data/lib/jasmine/doc/symbols/jasmine.Runner.html +710 -0
  28. data/lib/jasmine/doc/symbols/jasmine.Spec.html +1253 -0
  29. data/lib/jasmine/doc/symbols/jasmine.Spy.html +855 -0
  30. data/lib/jasmine/doc/symbols/jasmine.Suite.html +705 -0
  31. data/lib/jasmine/doc/symbols/jasmine.html +1345 -0
  32. data/lib/jasmine/doc/symbols/jasmine.util.html +535 -0
  33. data/lib/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +124 -0
  34. data/lib/jasmine/doc/symbols/src/src_Block.js.html +29 -0
  35. data/lib/jasmine/doc/symbols/src/src_Env.js.html +248 -0
  36. data/lib/jasmine/doc/symbols/src/src_JsApiReporter.js.html +111 -0
  37. data/lib/jasmine/doc/symbols/src/src_Matchers.js.html +344 -0
  38. data/lib/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
  39. data/lib/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
  40. data/lib/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +130 -0
  41. data/lib/jasmine/doc/symbols/src/src_Queue.js.html +102 -0
  42. data/lib/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
  43. data/lib/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
  44. data/lib/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
  45. data/lib/jasmine/doc/symbols/src/src_Spec.js.html +214 -0
  46. data/lib/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
  47. data/lib/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
  48. data/lib/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
  49. data/lib/jasmine/doc/symbols/src/src_base.js.html +585 -0
  50. data/lib/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
  51. data/lib/jasmine/doc/symbols/src/src_util.js.html +75 -0
  52. data/lib/jasmine/example/example_runner.html +22 -0
  53. data/lib/jasmine/example/spec/example_suite.js +11 -0
  54. data/lib/jasmine/images/fail-16.png +0 -0
  55. data/lib/jasmine/images/fail.png +0 -0
  56. data/lib/jasmine/images/go-16.png +0 -0
  57. data/lib/jasmine/images/go.png +0 -0
  58. data/lib/jasmine/images/pending-16.png +0 -0
  59. data/lib/jasmine/images/pending.png +0 -0
  60. data/lib/jasmine/images/question-bk.png +0 -0
  61. data/lib/jasmine/images/questionbk-16.png +0 -0
  62. data/lib/jasmine/images/spinner.gif +0 -0
  63. data/lib/jasmine/lib/TrivialReporter.js +171 -0
  64. data/lib/jasmine/lib/consolex.js +28 -0
  65. data/lib/jasmine/lib/jasmine-0.10.4.js +2371 -0
  66. data/lib/jasmine/lib/jasmine.css +166 -0
  67. data/lib/jasmine/lib/json2.js +478 -0
  68. data/lib/jasmine/spec/jasmine_helper.rb +44 -0
  69. data/lib/jasmine/spec/jasmine_spec.rb +31 -0
  70. data/lib/jasmine/spec/runner.html +80 -0
  71. data/lib/jasmine/spec/saucelabs.yml +24 -0
  72. data/lib/jasmine/spec/suites/CustomMatchersSpec.js +112 -0
  73. data/lib/jasmine/spec/suites/EnvSpec.js +158 -0
  74. data/lib/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  75. data/lib/jasmine/spec/suites/JsApiReporterSpec.js +96 -0
  76. data/lib/jasmine/spec/suites/MatchersSpec.js +709 -0
  77. data/lib/jasmine/spec/suites/MockClockSpec.js +34 -0
  78. data/lib/jasmine/spec/suites/MultiReporterSpec.js +30 -0
  79. data/lib/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  80. data/lib/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  81. data/lib/jasmine/spec/suites/QueueSpec.js +23 -0
  82. data/lib/jasmine/spec/suites/ReporterSpec.js +60 -0
  83. data/lib/jasmine/spec/suites/RunnerSpec.js +267 -0
  84. data/lib/jasmine/spec/suites/SpecRunningSpec.js +1195 -0
  85. data/lib/jasmine/spec/suites/SpecSpec.js +110 -0
  86. data/lib/jasmine/spec/suites/SpySpec.js +201 -0
  87. data/lib/jasmine/spec/suites/SuiteSpec.js +120 -0
  88. data/lib/jasmine/spec/suites/TrivialReporterSpec.js +158 -0
  89. data/lib/jasmine/spec/suites/UtilSpec.js +40 -0
  90. data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +88 -0
  91. data/lib/jasmine/src/Block.js +22 -0
  92. data/lib/jasmine/src/Env.js +263 -0
  93. data/lib/jasmine/src/JsApiReporter.js +104 -0
  94. data/lib/jasmine/src/Matchers.js +336 -0
  95. data/lib/jasmine/src/MultiReporter.js +28 -0
  96. data/lib/jasmine/src/NestedResults.js +80 -0
  97. data/lib/jasmine/src/PrettyPrinter.js +122 -0
  98. data/lib/jasmine/src/Queue.js +94 -0
  99. data/lib/jasmine/src/Reporter.js +27 -0
  100. data/lib/jasmine/src/Reporters.js +43 -0
  101. data/lib/jasmine/src/Runner.js +77 -0
  102. data/lib/jasmine/src/Spec.js +206 -0
  103. data/lib/jasmine/src/Suite.js +82 -0
  104. data/lib/jasmine/src/WaitsBlock.js +13 -0
  105. data/lib/jasmine/src/WaitsForBlock.js +37 -0
  106. data/lib/jasmine/src/base.js +586 -0
  107. data/lib/jasmine/src/mock-timeout.js +177 -0
  108. data/lib/jasmine/src/util.js +67 -0
  109. data/lib/jasmine/src/version.json +5 -0
  110. metadata +238 -0
@@ -0,0 +1,336 @@
1
+ /**
2
+ * @constructor
3
+ * @param {jasmine.Env} env
4
+ * @param actual
5
+ * @param {jasmine.Spec} spec
6
+ */
7
+ jasmine.Matchers = function(env, actual, spec, opt_isNot) {
8
+ this.env = env;
9
+ this.actual = actual;
10
+ this.spec = spec;
11
+ this.isNot = opt_isNot || false;
12
+ this.reportWasCalled_ = false;
13
+ };
14
+
15
+ // todo: @deprecated as of Jasmine 0.11, remove soon [xw]
16
+ jasmine.Matchers.pp = function(str) {
17
+ throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
18
+ this.report();
19
+ };
20
+
21
+ /** @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. */
22
+ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
23
+ // todo: report a deprecation warning [xw]
24
+
25
+ if (this.isNot) {
26
+ throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
27
+ }
28
+
29
+ this.reportWasCalled_ = true;
30
+ var expectationResult = new jasmine.ExpectationResult({
31
+ passed: result,
32
+ message: failing_message,
33
+ details: details
34
+ });
35
+ this.spec.addMatcherResult(expectationResult);
36
+ return result;
37
+ };
38
+
39
+ jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
40
+ for (var methodName in prototype) {
41
+ if (methodName == 'report') continue;
42
+ var orig = prototype[methodName];
43
+ matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
44
+ }
45
+ };
46
+
47
+ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
48
+ return function() {
49
+ var matcherArgs = jasmine.util.argsToArray(arguments);
50
+ var result = matcherFunction.apply(this, arguments);
51
+
52
+ if (this.isNot) {
53
+ result = !result;
54
+ }
55
+
56
+ if (this.reportWasCalled_) return result;
57
+
58
+ var message;
59
+ if (!result) {
60
+ if (this.message) {
61
+ message = this.message.apply(this, arguments);
62
+ if (jasmine.isArray_(message)) {
63
+ message = message[this.isNot ? 1 : 0];
64
+ }
65
+ } else {
66
+ var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
67
+ message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
68
+ if (matcherArgs.length > 0) {
69
+ for (var i = 0; i < matcherArgs.length; i++) {
70
+ if (i > 0) message += ",";
71
+ message += " " + jasmine.pp(matcherArgs[i]);
72
+ }
73
+ }
74
+ message += ".";
75
+ }
76
+ }
77
+ var expectationResult = new jasmine.ExpectationResult({
78
+ matcherName: matcherName,
79
+ passed: result,
80
+ expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
81
+ actual: this.actual,
82
+ message: message
83
+ });
84
+ this.spec.addMatcherResult(expectationResult);
85
+ return result;
86
+ };
87
+ };
88
+
89
+
90
+
91
+
92
+ /**
93
+ * toBe: compares the actual to the expected using ===
94
+ * @param expected
95
+ */
96
+ jasmine.Matchers.prototype.toBe = function(expected) {
97
+ return this.actual === expected;
98
+ };
99
+
100
+ /**
101
+ * toNotBe: compares the actual to the expected using !==
102
+ * @param expected
103
+ */
104
+ jasmine.Matchers.prototype.toNotBe = function(expected) {
105
+ return this.actual !== expected;
106
+ };
107
+
108
+ /**
109
+ * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
110
+ *
111
+ * @param expected
112
+ */
113
+ jasmine.Matchers.prototype.toEqual = function(expected) {
114
+ return this.env.equals_(this.actual, expected);
115
+ };
116
+
117
+ /**
118
+ * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
119
+ * @param expected
120
+ */
121
+ jasmine.Matchers.prototype.toNotEqual = function(expected) {
122
+ return !this.env.equals_(this.actual, expected);
123
+ };
124
+
125
+ /**
126
+ * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
127
+ * a pattern or a String.
128
+ *
129
+ * @param expected
130
+ */
131
+ jasmine.Matchers.prototype.toMatch = function(expected) {
132
+ return new RegExp(expected).test(this.actual);
133
+ };
134
+
135
+ /**
136
+ * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
137
+ * @param expected
138
+ */
139
+ jasmine.Matchers.prototype.toNotMatch = function(expected) {
140
+ return !(new RegExp(expected).test(this.actual));
141
+ };
142
+
143
+ /**
144
+ * Matcher that compares the actual to jasmine.undefined.
145
+ */
146
+ jasmine.Matchers.prototype.toBeDefined = function() {
147
+ return (this.actual !== jasmine.undefined);
148
+ };
149
+
150
+ /**
151
+ * Matcher that compares the actual to jasmine.undefined.
152
+ */
153
+ jasmine.Matchers.prototype.toBeUndefined = function() {
154
+ return (this.actual === jasmine.undefined);
155
+ };
156
+
157
+ /**
158
+ * Matcher that compares the actual to null.
159
+ */
160
+ jasmine.Matchers.prototype.toBeNull = function() {
161
+ return (this.actual === null);
162
+ };
163
+
164
+ /**
165
+ * Matcher that boolean not-nots the actual.
166
+ */
167
+ jasmine.Matchers.prototype.toBeTruthy = function() {
168
+ return !!this.actual;
169
+ };
170
+
171
+
172
+ /**
173
+ * Matcher that boolean nots the actual.
174
+ */
175
+ jasmine.Matchers.prototype.toBeFalsy = function() {
176
+ return !this.actual;
177
+ };
178
+
179
+ /**
180
+ * Matcher that checks to see if the actual, a Jasmine spy, was called.
181
+ */
182
+ jasmine.Matchers.prototype.wasCalled = function() {
183
+ if (arguments.length > 0) {
184
+ throw new Error('wasCalled does not take arguments, use wasCalledWith');
185
+ }
186
+
187
+ if (!jasmine.isSpy(this.actual)) {
188
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
189
+ }
190
+
191
+ this.message = function() {
192
+ return "Expected spy " + this.actual.identity + " to have been called.";
193
+ };
194
+
195
+ return this.actual.wasCalled;
196
+ };
197
+
198
+ /**
199
+ * Matcher that checks to see if the actual, a Jasmine spy, was not called.
200
+ */
201
+ jasmine.Matchers.prototype.wasNotCalled = function() {
202
+ if (arguments.length > 0) {
203
+ throw new Error('wasNotCalled does not take arguments');
204
+ }
205
+
206
+ if (!jasmine.isSpy(this.actual)) {
207
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
208
+ }
209
+
210
+ this.message = function() {
211
+ return "Expected spy " + this.actual.identity + " to not have been called.";
212
+ };
213
+
214
+ return !this.actual.wasCalled;
215
+ };
216
+
217
+ /**
218
+ * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
219
+ *
220
+ * @example
221
+ *
222
+ */
223
+ jasmine.Matchers.prototype.wasCalledWith = function() {
224
+ var expectedArgs = jasmine.util.argsToArray(arguments);
225
+ if (!jasmine.isSpy(this.actual)) {
226
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
227
+ }
228
+ this.message = function() {
229
+ if (this.actual.callCount == 0) {
230
+ return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
231
+ } else {
232
+ return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall);
233
+ }
234
+ };
235
+
236
+ return this.env.contains_(this.actual.argsForCall, expectedArgs);
237
+ };
238
+
239
+ jasmine.Matchers.prototype.wasNotCalledWith = function() {
240
+ var expectedArgs = jasmine.util.argsToArray(arguments);
241
+ if (!jasmine.isSpy(this.actual)) {
242
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
243
+ }
244
+
245
+ this.message = function() {
246
+ return "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was";
247
+ };
248
+
249
+ return !this.env.contains_(this.actual.argsForCall, expectedArgs);
250
+ };
251
+
252
+ /**
253
+ * Matcher that checks that the expected item is an element in the actual Array.
254
+ *
255
+ * @param {Object} expected
256
+ */
257
+ jasmine.Matchers.prototype.toContain = function(expected) {
258
+ return this.env.contains_(this.actual, expected);
259
+ };
260
+
261
+ /**
262
+ * Matcher that checks that the expected item is NOT an element in the actual Array.
263
+ *
264
+ * @param {Object} expected
265
+ */
266
+ jasmine.Matchers.prototype.toNotContain = function(expected) {
267
+ return !this.env.contains_(this.actual, expected);
268
+ };
269
+
270
+ jasmine.Matchers.prototype.toBeLessThan = function(expected) {
271
+ return this.actual < expected;
272
+ };
273
+
274
+ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
275
+ return this.actual > expected;
276
+ };
277
+
278
+ /**
279
+ * Matcher that checks that the expected exception was thrown by the actual.
280
+ *
281
+ * @param {String} expected
282
+ */
283
+ jasmine.Matchers.prototype.toThrow = function(expected) {
284
+ var result = false;
285
+ var exception;
286
+ if (typeof this.actual != 'function') {
287
+ throw new Error('Actual is not a function');
288
+ }
289
+ try {
290
+ this.actual();
291
+ } catch (e) {
292
+ exception = e;
293
+ }
294
+ if (exception) {
295
+ result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
296
+ }
297
+
298
+ this.message = function() {
299
+ if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
300
+ return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' ');
301
+ } else {
302
+ return "Expected function to throw an exception.";
303
+ }
304
+ };
305
+
306
+ return result;
307
+ };
308
+
309
+ jasmine.Matchers.Any = function(expectedClass) {
310
+ this.expectedClass = expectedClass;
311
+ };
312
+
313
+ jasmine.Matchers.Any.prototype.matches = function(other) {
314
+ if (this.expectedClass == String) {
315
+ return typeof other == 'string' || other instanceof String;
316
+ }
317
+
318
+ if (this.expectedClass == Number) {
319
+ return typeof other == 'number' || other instanceof Number;
320
+ }
321
+
322
+ if (this.expectedClass == Function) {
323
+ return typeof other == 'function' || other instanceof Function;
324
+ }
325
+
326
+ if (this.expectedClass == Object) {
327
+ return typeof other == 'object';
328
+ }
329
+
330
+ return other instanceof this.expectedClass;
331
+ };
332
+
333
+ jasmine.Matchers.Any.prototype.toString = function() {
334
+ return '<jasmine.any(' + this.expectedClass + ')>';
335
+ };
336
+
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @constructor
3
+ */
4
+ jasmine.MultiReporter = function() {
5
+ this.subReporters_ = [];
6
+ };
7
+ jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
8
+
9
+ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
10
+ this.subReporters_.push(reporter);
11
+ };
12
+
13
+ (function() {
14
+ var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
15
+ for (var i = 0; i < functionNames.length; i++) {
16
+ var functionName = functionNames[i];
17
+ jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
18
+ return function() {
19
+ for (var j = 0; j < this.subReporters_.length; j++) {
20
+ var subReporter = this.subReporters_[j];
21
+ if (subReporter[functionName]) {
22
+ subReporter[functionName].apply(subReporter, arguments);
23
+ }
24
+ }
25
+ };
26
+ })(functionName);
27
+ }
28
+ })();
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
3
+ *
4
+ * @constructor
5
+ */
6
+ jasmine.NestedResults = function() {
7
+ /**
8
+ * The total count of results
9
+ */
10
+ this.totalCount = 0;
11
+ /**
12
+ * Number of passed results
13
+ */
14
+ this.passedCount = 0;
15
+ /**
16
+ * Number of failed results
17
+ */
18
+ this.failedCount = 0;
19
+ /**
20
+ * Was this suite/spec skipped?
21
+ */
22
+ this.skipped = false;
23
+ /**
24
+ * @ignore
25
+ */
26
+ this.items_ = [];
27
+ };
28
+
29
+ /**
30
+ * Roll up the result counts.
31
+ *
32
+ * @param result
33
+ */
34
+ jasmine.NestedResults.prototype.rollupCounts = function(result) {
35
+ this.totalCount += result.totalCount;
36
+ this.passedCount += result.passedCount;
37
+ this.failedCount += result.failedCount;
38
+ };
39
+
40
+ /**
41
+ * Tracks a result's message.
42
+ * @param message
43
+ */
44
+ jasmine.NestedResults.prototype.log = function(message) {
45
+ this.items_.push(new jasmine.MessageResult(message));
46
+ };
47
+
48
+ /**
49
+ * Getter for the results: message & results.
50
+ */
51
+ jasmine.NestedResults.prototype.getItems = function() {
52
+ return this.items_;
53
+ };
54
+
55
+ /**
56
+ * Adds a result, tracking counts (total, passed, & failed)
57
+ * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
58
+ */
59
+ jasmine.NestedResults.prototype.addResult = function(result) {
60
+ if (result.type != 'MessageResult') {
61
+ if (result.items_) {
62
+ this.rollupCounts(result);
63
+ } else {
64
+ this.totalCount++;
65
+ if (result.passed()) {
66
+ this.passedCount++;
67
+ } else {
68
+ this.failedCount++;
69
+ }
70
+ }
71
+ }
72
+ this.items_.push(result);
73
+ };
74
+
75
+ /**
76
+ * @returns {Boolean} True if <b>everything</b> below passed
77
+ */
78
+ jasmine.NestedResults.prototype.passed = function() {
79
+ return this.passedCount === this.totalCount;
80
+ };
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Base class for pretty printing for expectation results.
3
+ */
4
+ jasmine.PrettyPrinter = function() {
5
+ this.ppNestLevel_ = 0;
6
+ };
7
+
8
+ /**
9
+ * Formats a value in a nice, human-readable string.
10
+ *
11
+ * @param value
12
+ */
13
+ jasmine.PrettyPrinter.prototype.format = function(value) {
14
+ if (this.ppNestLevel_ > 40) {
15
+ throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
16
+ }
17
+
18
+ this.ppNestLevel_++;
19
+ try {
20
+ if (value === jasmine.undefined) {
21
+ this.emitScalar('undefined');
22
+ } else if (value === null) {
23
+ this.emitScalar('null');
24
+ } else if (value.navigator && value.frames && value.setTimeout) {
25
+ this.emitScalar('<window>');
26
+ } else if (value instanceof jasmine.Matchers.Any) {
27
+ this.emitScalar(value.toString());
28
+ } else if (typeof value === 'string') {
29
+ this.emitString(value);
30
+ } else if (jasmine.isSpy(value)) {
31
+ this.emitScalar("spy on " + value.identity);
32
+ } else if (value instanceof RegExp) {
33
+ this.emitScalar(value.toString());
34
+ } else if (typeof value === 'function') {
35
+ this.emitScalar('Function');
36
+ } else if (typeof value.nodeType === 'number') {
37
+ this.emitScalar('HTMLNode');
38
+ } else if (value instanceof Date) {
39
+ this.emitScalar('Date(' + value + ')');
40
+ } else if (value.__Jasmine_been_here_before__) {
41
+ this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
42
+ } else if (jasmine.isArray_(value) || typeof value == 'object') {
43
+ value.__Jasmine_been_here_before__ = true;
44
+ if (jasmine.isArray_(value)) {
45
+ this.emitArray(value);
46
+ } else {
47
+ this.emitObject(value);
48
+ }
49
+ delete value.__Jasmine_been_here_before__;
50
+ } else {
51
+ this.emitScalar(value.toString());
52
+ }
53
+ } finally {
54
+ this.ppNestLevel_--;
55
+ }
56
+ };
57
+
58
+ jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
59
+ for (var property in obj) {
60
+ if (property == '__Jasmine_been_here_before__') continue;
61
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
62
+ }
63
+ };
64
+
65
+ jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
66
+ jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
67
+ jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
68
+ jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
69
+
70
+ jasmine.StringPrettyPrinter = function() {
71
+ jasmine.PrettyPrinter.call(this);
72
+
73
+ this.string = '';
74
+ };
75
+ jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
76
+
77
+ jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
78
+ this.append(value);
79
+ };
80
+
81
+ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
82
+ this.append("'" + value + "'");
83
+ };
84
+
85
+ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
86
+ this.append('[ ');
87
+ for (var i = 0; i < array.length; i++) {
88
+ if (i > 0) {
89
+ this.append(', ');
90
+ }
91
+ this.format(array[i]);
92
+ }
93
+ this.append(' ]');
94
+ };
95
+
96
+ jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
97
+ var self = this;
98
+ this.append('{ ');
99
+ var first = true;
100
+
101
+ this.iterateObject(obj, function(property, isGetter) {
102
+ if (first) {
103
+ first = false;
104
+ } else {
105
+ self.append(', ');
106
+ }
107
+
108
+ self.append(property);
109
+ self.append(' : ');
110
+ if (isGetter) {
111
+ self.append('<getter>');
112
+ } else {
113
+ self.format(obj[property]);
114
+ }
115
+ });
116
+
117
+ this.append(' }');
118
+ };
119
+
120
+ jasmine.StringPrettyPrinter.prototype.append = function(value) {
121
+ this.string += value;
122
+ };