Skip to content

Commit 3881d1d

Browse files
committed
Switching to Jasmine for testing
1 parent 4e4ad6a commit 3881d1d

File tree

11 files changed

+3859
-0
lines changed

11 files changed

+3859
-0
lines changed

spec/JsTestDriver-1.3.5.jar

4.12 MB
Binary file not shown.

spec/SpecRunner.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Jasmine Spec Runner</title>
5+
6+
<link rel="stylesheet" type="text/css" href="lib/jasmine.css">
7+
8+
<script type="text/javascript" src="lib/jasmine.js"></script>
9+
<script type="text/javascript" src="lib/jasmine-html.js"></script>
10+
11+
<script type="text/javascript" src="../error-parser.js"></script>
12+
13+
<script type="text/javascript" src="captured-errors.js"></script>
14+
<script type="text/javascript" src="error-parser-test.js"></script>
15+
16+
<script type="text/javascript">
17+
(function() {
18+
var jasmineEnv = jasmine.getEnv();
19+
jasmineEnv.updateInterval = 1000;
20+
21+
var htmlReporter = new jasmine.HtmlReporter();
22+
23+
jasmineEnv.addReporter(htmlReporter);
24+
25+
jasmineEnv.specFilter = function(spec) {
26+
return htmlReporter.specFilter(spec);
27+
};
28+
29+
var currentWindowOnload = window.onload;
30+
31+
window.onload = function() {
32+
if(currentWindowOnload) {
33+
currentWindowOnload();
34+
}
35+
execJasmine();
36+
};
37+
38+
function execJasmine() {
39+
jasmineEnv.execute();
40+
}
41+
})();
42+
</script>
43+
</head>
44+
<body>
45+
</body>
46+
</html>

spec/captured-errors.js

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
var CapturedExceptions = {};
2+
3+
CapturedExceptions.opera_854 = {
4+
message: "Statement on line 44: Type mismatch (usually a non-object value used where an object is required)\n" +
5+
"Backtrace:\n" +
6+
" Line 44 of linked script file://localhost/G:/js/stacktrace.js\n" +
7+
" this.undef();\n" +
8+
" Line 31 of linked script file://localhost/G:/js/stacktrace.js\n" +
9+
" ex = ex || this.createException();\n" +
10+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js\n" +
11+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
12+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
13+
" printTrace(printStackTrace());\n" +
14+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
15+
" bar(n - 1);\n" +
16+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
17+
" bar(2);\n" +
18+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
19+
" foo();\n" +
20+
"",
21+
'opera#sourceloc': 44
22+
};
23+
24+
CapturedExceptions.opera_902 = {
25+
message: "Statement on line 44: Type mismatch (usually a non-object value used where an object is required)\n" +
26+
"Backtrace:\n" +
27+
" Line 44 of linked script file://localhost/G:/js/stacktrace.js\n" +
28+
" this.undef();\n" +
29+
" Line 31 of linked script file://localhost/G:/js/stacktrace.js\n" +
30+
" ex = ex || this.createException();\n" +
31+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js\n" +
32+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
33+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
34+
" printTrace(printStackTrace());\n" +
35+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
36+
" bar(n - 1);\n" +
37+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
38+
" bar(2);\n" +
39+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
40+
" foo();\n" +
41+
"",
42+
'opera#sourceloc': 44
43+
};
44+
45+
CapturedExceptions.opera_927 = {
46+
message: "Statement on line 43: Type mismatch (usually a non-object value used where an object is required)\n" +
47+
"Backtrace:\n" +
48+
" Line 43 of linked script file://localhost/G:/js/stacktrace.js\n" +
49+
" this.undef();\n" +
50+
" Line 31 of linked script file://localhost/G:/js/stacktrace.js\n" +
51+
" ex = ex || this.createException();\n" +
52+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js\n" +
53+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
54+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
55+
" printTrace(printStackTrace());\n" +
56+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
57+
" bar(n - 1);\n" +
58+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
59+
" bar(2);\n" +
60+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
61+
" foo();\n" +
62+
"",
63+
'opera#sourceloc': 43
64+
};
65+
66+
CapturedExceptions.opera_964 = {
67+
message: "Statement on line 42: Type mismatch (usually non-object value supplied where object required)\n" +
68+
"Backtrace:\n" +
69+
" Line 42 of linked script file://localhost/G:/js/stacktrace.js\n" +
70+
" this.undef();\n" +
71+
" Line 27 of linked script file://localhost/G:/js/stacktrace.js\n" +
72+
" ex = ex || this.createException();\n" +
73+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js: In function printStackTrace\n" +
74+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
75+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
76+
" printTrace(printStackTrace());\n" +
77+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
78+
" bar(n - 1);\n" +
79+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n" +
80+
" bar(2);\n" +
81+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
82+
" foo();\n" +
83+
"",
84+
'opera#sourceloc': 42,
85+
stacktrace: " ... Line 27 of linked script file://localhost/G:/js/stacktrace.js\n" +
86+
" ex = ex || this.createException();\n" +
87+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js: In function printStackTrace\n" +
88+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
89+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
90+
" printTrace(printStackTrace());\n" +
91+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
92+
" bar(n - 1);\n" +
93+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n" +
94+
" bar(2);\n" +
95+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
96+
" foo();\n" +
97+
""
98+
};
99+
100+
CapturedExceptions.opera_1010 = {
101+
message: "Statement on line 42: Type mismatch (usually non-object value supplied where object required)",
102+
'opera#sourceloc': 42,
103+
stacktrace: " Line 42 of linked script file://localhost/G:/js/stacktrace.js\n" +
104+
" this.undef();\n" +
105+
" Line 27 of linked script file://localhost/G:/js/stacktrace.js\n" +
106+
" ex = ex || this.createException();\n" +
107+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js: In function printStackTrace\n" +
108+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
109+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
110+
" printTrace(printStackTrace());\n" +
111+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
112+
" bar(n - 1);\n" +
113+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n" +
114+
" bar(2);\n" +
115+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
116+
" foo();\n" +
117+
""
118+
};
119+
120+
CapturedExceptions.opera_1063 = {
121+
message: "'this.undef' is not a function",
122+
stack: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
123+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
124+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
125+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
126+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
127+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
128+
"@file://localhost/G:/js/test/functional/testcase1.html:15",
129+
stacktrace: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
130+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
131+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
132+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
133+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
134+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
135+
"@file://localhost/G:/js/test/functional/testcase1.html:15"
136+
};
137+
138+
CapturedExceptions.opera_1111 = {
139+
message: "'this.undef' is not a function",
140+
stack: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
141+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
142+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
143+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
144+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
145+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
146+
"@file://localhost/G:/js/test/functional/testcase1.html:15",
147+
stacktrace: "Error thrown at line 42, column 12 in <anonymous function: createException>() in file://localhost/G:/js/stacktrace.js:\n" +
148+
" this.undef();\n" +
149+
"called from line 27, column 8 in <anonymous function: run>(ex) in file://localhost/G:/js/stacktrace.js:\n" +
150+
" ex = ex || this.createException();\n" +
151+
"called from line 18, column 4 in printStackTrace(options) in file://localhost/G:/js/stacktrace.js:\n" +
152+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
153+
"called from line 4, column 5 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
154+
" printTrace(printStackTrace());\n" +
155+
"called from line 7, column 4 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
156+
" bar(n - 1);\n" +
157+
"called from line 11, column 4 in foo() in file://localhost/G:/js/test/functional/testcase1.html:\n" +
158+
" bar(2);\n" +
159+
"called from line 15, column 3 in file://localhost/G:/js/test/functional/testcase1.html:\n" +
160+
" foo();"
161+
};
162+
163+
CapturedExceptions.opera_1151 = {
164+
message: "'this.undef' is not a function",
165+
stack: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
166+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
167+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
168+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
169+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
170+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
171+
"@file://localhost/G:/js/test/functional/testcase1.html:15",
172+
stacktrace: "Error thrown at line 42, column 12 in <anonymous function: createException>() in file://localhost/G:/js/stacktrace.js:\n" +
173+
" this.undef();\n" +
174+
"called from line 27, column 8 in <anonymous function: run>(ex) in file://localhost/G:/js/stacktrace.js:\n" +
175+
" ex = ex || this.createException();\n" +
176+
"called from line 18, column 4 in printStackTrace(options) in file://localhost/G:/js/stacktrace.js:\n" +
177+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
178+
"called from line 4, column 5 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
179+
" printTrace(printStackTrace());\n" +
180+
"called from line 7, column 4 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
181+
" bar(n - 1);\n" +
182+
"called from line 11, column 4 in foo() in file://localhost/G:/js/test/functional/testcase1.html:\n" +
183+
" bar(2);\n" +
184+
"called from line 15, column 3 in file://localhost/G:/js/test/functional/testcase1.html:\n" +
185+
" foo();"
186+
};
187+
188+
CapturedExceptions.chrome_15 = {
189+
'arguments': ["undef"],
190+
message: "Object #<Object> has no method 'undef'",
191+
stack: "TypeError: Object #<Object> has no method 'undef'\n" +
192+
" at Object.createException (http://127.0.0.1:8000/js/stacktrace.js:42:18)\n" +
193+
" at Object.run (http://127.0.0.1:8000/js/stacktrace.js:31:25)\n" +
194+
" at printStackTrace (http://127.0.0.1:8000/js/stacktrace.js:18:62)\n" +
195+
" at bar (http://127.0.0.1:8000/js/test/functional/testcase1.html:13:17)\n" +
196+
" at bar (http://127.0.0.1:8000/js/test/functional/testcase1.html:16:5)\n" +
197+
" at foo (http://127.0.0.1:8000/js/test/functional/testcase1.html:20:5)\n" +
198+
" at http://127.0.0.1:8000/js/test/functional/testcase1.html:24:4"
199+
};
200+
201+
CapturedExceptions.firefox_36 = {
202+
fileName: "http://127.0.0.1:8000/js/stacktrace.js",
203+
lineNumber: 44,
204+
message: "this.undef is not a function",
205+
name: "TypeError",
206+
stack: "()@http://127.0.0.1:8000/js/stacktrace.js:44\n" +
207+
"(null)@http://127.0.0.1:8000/js/stacktrace.js:31\n" +
208+
"printStackTrace()@http://127.0.0.1:8000/js/stacktrace.js:18\n" +
209+
"bar(1)@http://127.0.0.1:8000/js/test/functional/testcase1.html:13\n" +
210+
"bar(2)@http://127.0.0.1:8000/js/test/functional/testcase1.html:16\n" +
211+
"foo()@http://127.0.0.1:8000/js/test/functional/testcase1.html:20\n" +
212+
"@http://127.0.0.1:8000/js/test/functional/testcase1.html:24\n" +
213+
""
214+
};
215+
216+
CapturedExceptions.firefox_36_file = {
217+
fileName: "file:///home/user/js/stacktrace.js",
218+
lineNumber: 44,
219+
message: "this.undef is not a function",
220+
name: "TypeError",
221+
stack: "()@file:///home/user/js/stacktrace.js:44\n" +
222+
"(null)@file:///home/user/js/stacktrace.js:31\n" +
223+
"printStackTrace()@file:///home/user/js/stacktrace.js:18\n" +
224+
"bar(1)@file:///home/user/js/test/functional/testcase1.html:13\n" +
225+
"bar(2)@file:///home/user/js/test/functional/testcase1.html:16\n" +
226+
"foo()@file:///home/user/js/test/functional/testcase1.html:20\n" +
227+
"@file:///home/user/js/test/functional/testcase1.html:24\n" +
228+
""
229+
};
230+
231+
CapturedExceptions.firefox_7 = {
232+
fileName: "file:///G:/js/stacktrace.js",
233+
lineNumber: 44,
234+
stack: "()@file:///G:/js/stacktrace.js:44\n" +
235+
"(null)@file:///G:/js/stacktrace.js:31\n" +
236+
"printStackTrace()@file:///G:/js/stacktrace.js:18\n" +
237+
"bar(1)@file:///G:/js/test/functional/testcase1.html:13\n" +
238+
"bar(2)@file:///G:/js/test/functional/testcase1.html:16\n" +
239+
"foo()@file:///G:/js/test/functional/testcase1.html:20\n" +
240+
"@file:///G:/js/test/functional/testcase1.html:24\n" +
241+
""
242+
};
243+
244+
CapturedExceptions.firefox_14 = {
245+
message: "x is null",
246+
stack: "@file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html:48\n" +
247+
"dumpException3@file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html:52\n" +
248+
"onclick@file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html:1\n" +
249+
"",
250+
fileName: "file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html",
251+
lineNumber: 48
252+
};
253+
254+
CapturedExceptions.safari_6 = {
255+
message: "'null' is not an object (evaluating 'x.undef')",
256+
stack: "@file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html:48\n" +
257+
"dumpException3@file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html:52\n" +
258+
"onclick@file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html:82\n" +
259+
"[native code]",
260+
line: 48,
261+
sourceURL: "file:///Users/eric/src/javascript-stacktrace/test/functional/ExceptionLab.html"
262+
};
263+
264+
CapturedExceptions.ie_10 = {
265+
message: "Unable to get property 'undef' of undefined or null reference",
266+
stack: "TypeError: Unable to get property 'undef' of undefined or null reference\n" +
267+
" at Anonymous function (http://jenkins.eriwen.com/job/stacktrace.js/ws/test/functional/ExceptionLab.html:48:13)\n" +
268+
" at dumpException3 (http://jenkins.eriwen.com/job/stacktrace.js/ws/test/functional/ExceptionLab.html:46:9)\n" +
269+
" at onclick (http://jenkins.eriwen.com/job/stacktrace.js/ws/test/functional/ExceptionLab.html:82:1)",
270+
description: "Unable to get property 'undef' of undefined or null reference",
271+
number: -2146823281
272+
};

spec/error-parser-test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('error-parser.js', function() {
2+
describe('ErrorParser', function() {
3+
describe('#chooseParser', function() {
4+
var errorParser = new ErrorParser();
5+
it('should detect V8', function() {
6+
expect(errorParser.chooseParser(CapturedExceptions.chrome_15)).toBe(errorParser.parseV8);
7+
});
8+
});
9+
});
10+
11+
// describe('Map::merge', function() {
12+
// it('should throw an Error if input is not a Map', function() {
13+
// var expectedError = new TypeError('Cannot merge with objects that are not Maps');
14+
// expect(function() { new Map().merge() }).toThrow(expectedError);
15+
// });
16+
//
17+
// it('should handle empty maps', function() {
18+
// var map = new Map();
19+
// var mergedMap = map.merge(new Map());
20+
// expect(mergedMap.keys().length).toBe(0);
21+
// });
22+
// });
23+
});

spec/jsTestDriver.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server: http://localhost:4224
2+
3+
load:
4+
- lib/jasmine.js
5+
- lib/JasmineAdapter.js
6+
- captured-errors.js
7+
- ../error-parser.js
8+
9+
test:
10+
- error-parser-test.js
11+
12+
plugin:
13+
- name: "coverage"
14+
jar: "lib/plugins/coverage-1.3.5.jar"
15+
module: "com.google.jstestdriver.coverage.CoverageModule"
16+
args: useCoberturaFormat
17+
18+
timeout: 30

0 commit comments

Comments
 (0)