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

Unified Diff: test/webkit/fast/js/kde/lval-exceptions.js

Issue 21070002: Migrate more tests from blink repository. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/webkit/fast/js/kde/literals-expected.txt ('k') | test/webkit/fast/js/kde/lval-exceptions-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/webkit/fast/js/kde/lval-exceptions.js
diff --git a/test/webkit/vardecl-blocks-init.js b/test/webkit/fast/js/kde/lval-exceptions.js
similarity index 50%
copy from test/webkit/vardecl-blocks-init.js
copy to test/webkit/fast/js/kde/lval-exceptions.js
index b77f191b7fe3ce23199e99b3d9f6fe0da4c28de6..32641f8d4da5b6b94dedee794918c1143c678f08 100644
--- a/test/webkit/vardecl-blocks-init.js
+++ b/test/webkit/fast/js/kde/lval-exceptions.js
@@ -21,57 +21,54 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-description(
-"This test checks that variable declarations with initializers inside of catch and with blocks do not set values in a deeper scope."
-);
+description("KDE JS Test");
+// Tests for raising --- and non-raising exceptions on access to reference to undefined things...
-function catchTest() {
- var e = "foo";
+// Locals should throw on access if undefined..
+fnShouldThrow(function() { a = x; }, ReferenceError);
- try {
- throw "bar";
- } catch (e) {
- var e = "baz";
- }
+// Read-modify-write versions of assignment should throw as well
+fnShouldThrow(function() { x += "foo"; }, ReferenceError);
- return e;
-}
+// Other reference types should just return undefined...
+a = new Object();
+fnShouldNotThrow(function() { b = a.x; });
+fnShouldNotThrow(function() { b = a['x']; });
+fnShouldNotThrow(function() { a['x'] += 'baz'; });
+shouldBe("a['x']", '"undefinedbaz"');
+fnShouldNotThrow(function() { b = a.y; });
+fnShouldNotThrow(function() { a.y += 'glarch'; });
+shouldBe("a['y']", '"undefinedglarch"');
-function catchTest2() {
- var e = "foo";
+// Helpers!
+function fnShouldThrow(f, exType)
+{
+ var exception;
+ var _av;
try {
- throw "bar";
+ _av = f();
} catch (e) {
- var e = "baz";
-
- return e;
+ exception = e;
}
-}
-function withTest() {
- var e = "foo"
- var object = { 'e' : "bar" };
-
- with (object) {
- var e = "baz";
- }
-
- return e;
+ if (exception) {
+ if (typeof exType == "undefined" || exception instanceof exType)
+ testPassed(f + " threw exception " + exception + ".");
+ else
+ testFailed(f + " should throw exception " + exType + ". Threw exception " + exception + ".");
+ } else if (typeof _av == "undefined")
+ testFailed(f + " should throw exception " + exType + ". Was undefined.");
+ else
+ testFailed(f + " should throw exception " + exType + ". Was " + _av + ".");
}
-function withTest2() {
- var e = "foo"
- var object = { 'e' : "bar" };
-
- with (object) {
- var e = "baz";
-
- return e;
+function fnShouldNotThrow(f)
+{
+ try {
+ f();
+ testPassed(f + " did not throw an exception");
+ } catch (e) {
+ testFailed(f + " threw an exception " + e + " when no exception expected");
}
-}
-
-shouldBe("catchTest()", "'foo'");
-shouldBe("catchTest2()", "'baz'");
-shouldBe("withTest()", "'foo'");
-shouldBe("withTest2()", "'baz'");
+}
« no previous file with comments | « test/webkit/fast/js/kde/literals-expected.txt ('k') | test/webkit/fast/js/kde/lval-exceptions-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698