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

Side by Side Diff: test/mjsunit/strict-mode.js

Issue 6474026: Strict mode assignment to undefined reference. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix presubmit. Created 9 years, 10 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 eval("var x = { get " + word + " () { 'use strict'; } };"); 328 eval("var x = { get " + word + " () { 'use strict'; } };");
329 eval("var x = { set " + word + " (value) { 'use strict'; } };"); 329 eval("var x = { set " + word + " (value) { 'use strict'; } };");
330 assertThrows("var x = { get foo(" + word + ") { 'use strict'; } };", SyntaxErr or); 330 assertThrows("var x = { get foo(" + word + ") { 'use strict'; } };", SyntaxErr or);
331 assertThrows("var x = { set foo(" + word + ") { 'use strict'; } };", SyntaxErr or); 331 assertThrows("var x = { set foo(" + word + ") { 'use strict'; } };", SyntaxErr or);
332 } 332 }
333 333
334 for (var i = 0; i < future_reserved_words.length; i++) { 334 for (var i = 0; i < future_reserved_words.length; i++) {
335 testFutureReservedWord(future_reserved_words[i]); 335 testFutureReservedWord(future_reserved_words[i]);
336 } 336 }
337 337
338 function testAssignToUndefined(should_throw) {
339 "use strict";
340 try {
341 possibly_undefined_variable_for_strict_mode_test = "should throw?";
342 } catch (e) {
343 assertTrue(should_throw, "strict mode");
344 assertInstanceof(e, ReferenceError, "strict mode");
345 return;
346 }
347 assertFalse(should_throw, "strict mode");
348 }
338 349
350 testAssignToUndefined(true);
351 testAssignToUndefined(true);
352 testAssignToUndefined(true);
353
354 possibly_undefined_variable_for_strict_mode_test = "value";
355
356 testAssignToUndefined(false);
357 testAssignToUndefined(false);
358 testAssignToUndefined(false);
359
360 delete possibly_undefined_variable_for_strict_mode_test;
361
362 testAssignToUndefined(true);
363 testAssignToUndefined(true);
364 testAssignToUndefined(true);
365
366 function repeat(n, f) {
367 for (var i = 0; i < n; i ++) { f(); }
368 }
369
370 repeat(10, function() { testAssignToUndefined(true); });
371 possibly_undefined_variable_for_strict_mode_test = "value";
372 repeat(10, function() { testAssignToUndefined(false); });
373 delete possibly_undefined_variable_for_strict_mode_test;
374 repeat(10, function() { testAssignToUndefined(true); });
375 possibly_undefined_variable_for_strict_mode_test = undefined;
376 repeat(10, function() { testAssignToUndefined(false); });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698