OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
11 // documentation and/or other materials provided with the distribution. | 11 // documentation and/or other materials provided with the distribution. |
12 // | 12 // |
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | 23 |
24 var wasPostTestScriptParsed = false; | 24 var wasPostTestScriptParsed = false; |
25 var errorMessage; | 25 |
| 26 function removeLink(text) |
| 27 { |
| 28 return text.replace(/<a[^>]*>/g, "").replace(/<\/a>/g, ""); |
| 29 } |
26 | 30 |
27 function description(msg) | 31 function description(msg) |
28 { | 32 { |
29 print(msg); | 33 print(removeLink(msg)); |
30 print("\nOn success, you will see a series of \"PASS\" messages, followed by
\"TEST COMPLETE\".\n"); | 34 print("\nOn success, you will see a series of \"PASS\" messages, followed by
\"TEST COMPLETE\".\n"); |
31 print(); | 35 print(); |
32 } | 36 } |
33 | 37 |
34 function debug(msg) | 38 function debug(msg) |
35 { | 39 { |
36 print(msg); | 40 print(msg); |
37 } | 41 } |
38 | 42 |
39 function escapeString(text) | 43 function escapeString(text) |
40 { | 44 { |
41 return text.replace(/\0/g, ""); | 45 return text.replace(/\0/g, ""); |
42 } | 46 } |
43 | 47 |
44 function testPassed(msg) | 48 function testPassed(msg) |
45 { | 49 { |
46 print("PASS", escapeString(msg)); | 50 print("PASS", escapeString(msg)); |
47 } | 51 } |
48 | 52 |
49 function testFailed(msg) | 53 function testFailed(msg) |
50 { | 54 { |
51 errorMessage = msg; | |
52 print("FAIL", escapeString(msg)); | 55 print("FAIL", escapeString(msg)); |
53 } | 56 } |
54 | 57 |
55 function areArraysEqual(_a, _b) | 58 function areArraysEqual(_a, _b) |
56 { | 59 { |
57 if (Object.prototype.toString.call(_a) != Object.prototype.toString.call([])
) | 60 if (Object.prototype.toString.call(_a) != Object.prototype.toString.call([])
) |
58 return false; | 61 return false; |
59 if (_a.length !== _b.length) | 62 if (_a.length !== _b.length) |
60 return false; | 63 return false; |
61 for (var i = 0; i < _a.length; i++) | 64 for (var i = 0; i < _a.length; i++) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 else | 169 else |
167 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an excepti
on" : _ev) + ". Threw exception " + exception + "."); | 170 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an excepti
on" : _ev) + ". Threw exception " + exception + "."); |
168 } else if (typeof _av == "undefined") | 171 } else if (typeof _av == "undefined") |
169 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception
" : _ev) + ". Was undefined."); | 172 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception
" : _ev) + ". Was undefined."); |
170 else | 173 else |
171 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception
" : _ev) + ". Was " + _av + "."); | 174 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception
" : _ev) + ". Was " + _av + "."); |
172 } | 175 } |
173 | 176 |
174 function isSuccessfullyParsed() | 177 function isSuccessfullyParsed() |
175 { | 178 { |
176 // FIXME: Remove this and only report unexpected syntax errors. | 179 successfullyParsed = true; |
177 if (!errorMessage) | |
178 successfullyParsed = true; | |
179 shouldBeTrue("successfullyParsed"); | 180 shouldBeTrue("successfullyParsed"); |
180 debug("\nTEST COMPLETE\n"); | 181 debug("\nTEST COMPLETE\n"); |
181 } | 182 } |
182 | 183 |
183 // It's possible for an async test to call finishJSTest() before js-test-post.js | 184 // It's possible for an async test to call finishJSTest() before js-test-post.js |
184 // has been parsed. | 185 // has been parsed. |
185 function finishJSTest() | 186 function finishJSTest() |
186 { | 187 { |
187 wasFinishJSTestCalled = true; | 188 wasFinishJSTestCalled = true; |
188 if (!wasPostTestScriptParsed) | 189 if (!wasPostTestScriptParsed) |
189 return; | 190 return; |
190 isSuccessfullyParsed(); | 191 isSuccessfullyParsed(); |
191 } | 192 } |
OLD | NEW |