Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: test/webkit/resources/standalone-pre.js

Issue 17260002: Add new test suite for migrated blink tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/webkit/resources/standalone-post.js ('k') | test/webkit/testcfg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions
6 // are met:
7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 //
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
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
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24 var wasPostTestScriptParsed = false;
25 var errorMessage;
26
27 function description(msg)
28 {
29 print(msg);
30 print("\nOn success, you will see a series of \"PASS\" messages, followed by \"TEST COMPLETE\".\n");
31 print();
32 }
33
34 function debug(msg)
35 {
36 print(msg);
37 }
38
39 function escapeString(text)
40 {
41 return text.replace(/\0/g, "");
42 }
43
44 function testPassed(msg)
45 {
46 print("PASS", escapeString(msg));
47 }
48
49 function testFailed(msg)
50 {
51 errorMessage = msg;
52 print("FAIL", escapeString(msg));
53 }
54
55 function areArraysEqual(_a, _b)
56 {
57 if (Object.prototype.toString.call(_a) != Object.prototype.toString.call([]) )
58 return false;
59 if (_a.length !== _b.length)
60 return false;
61 for (var i = 0; i < _a.length; i++)
62 if (_a[i] !== _b[i])
63 return false;
64 return true;
65 }
66
67 function isMinusZero(n)
68 {
69 // the only way to tell 0 from -0 in JS is the fact that 1/-0 is
70 // -Infinity instead of Infinity
71 return n === 0 && 1/n < 0;
72 }
73
74 function isResultCorrect(_actual, _expected)
75 {
76 if (_expected === 0)
77 return _actual === _expected && (1/_actual) === (1/_expected);
78 if (_actual === _expected)
79 return true;
80 if (typeof(_expected) == "number" && isNaN(_expected))
81 return typeof(_actual) == "number" && isNaN(_actual);
82 if (Object.prototype.toString.call(_expected) == Object.prototype.toString.c all([]))
83 return areArraysEqual(_actual, _expected);
84 return false;
85 }
86
87 function stringify(v)
88 {
89 if (v === 0 && 1/v < 0)
90 return "-0";
91 else return "" + v;
92 }
93
94 function shouldBe(_a, _b)
95 {
96 if (typeof _a != "string" || typeof _b != "string")
97 debug("WARN: shouldBe() expects string arguments");
98 var exception;
99 var _av;
100 try {
101 _av = eval(_a);
102 } catch (e) {
103 exception = e;
104 }
105 var _bv = eval(_b);
106
107 if (exception)
108 testFailed(_a + " should be " + _bv + ". Threw exception " + exception);
109 else if (isResultCorrect(_av, _bv))
110 testPassed(_a + " is " + _b);
111 else if (typeof(_av) == typeof(_bv))
112 testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + ".");
113 else
114 testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
115 }
116
117 function shouldBeTrue(_a) { shouldBe(_a, "true"); }
118 function shouldBeFalse(_a) { shouldBe(_a, "false"); }
119 function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
120 function shouldBeNull(_a) { shouldBe(_a, "null"); }
121
122 function shouldBeEqualToString(a, b)
123 {
124 if (typeof a !== "string" || typeof b !== "string")
125 debug("WARN: shouldBeEqualToString() expects string arguments");
126 var unevaledString = JSON.stringify(b);
127 shouldBe(a, unevaledString);
128 }
129
130 function shouldBeUndefined(_a)
131 {
132 var exception;
133 var _av;
134 try {
135 _av = eval(_a);
136 } catch (e) {
137 exception = e;
138 }
139
140 if (exception)
141 testFailed(_a + " should be undefined. Threw exception " + exception);
142 else if (typeof _av == "undefined")
143 testPassed(_a + " is undefined.");
144 else
145 testFailed(_a + " should be undefined. Was " + _av);
146 }
147
148
149 function shouldThrow(_a, _e)
150 {
151 var exception;
152 var _av;
153 try {
154 _av = eval(_a);
155 } catch (e) {
156 exception = e;
157 }
158
159 var _ev;
160 if (_e)
161 _ev = eval(_e);
162
163 if (exception) {
164 if (typeof _e == "undefined" || exception == _ev)
165 testPassed(_a + " threw exception " + exception + ".");
166 else
167 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an excepti on" : _ev) + ". Threw exception " + exception + ".");
168 } else if (typeof _av == "undefined")
169 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception " : _ev) + ". Was undefined.");
170 else
171 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception " : _ev) + ". Was " + _av + ".");
172 }
173
174 function isSuccessfullyParsed()
175 {
176 // FIXME: Remove this and only report unexpected syntax errors.
177 if (!errorMessage)
178 successfullyParsed = true;
179 shouldBeTrue("successfullyParsed");
180 debug("\nTEST COMPLETE\n");
181 }
182
183 // It's possible for an async test to call finishJSTest() before js-test-post.js
184 // has been parsed.
185 function finishJSTest()
186 {
187 wasFinishJSTestCalled = true;
188 if (!wasPostTestScriptParsed)
189 return;
190 isSuccessfullyParsed();
191 }
OLDNEW
« no previous file with comments | « test/webkit/resources/standalone-post.js ('k') | test/webkit/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698