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

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

Issue 6523052: CallIC and KeyedCallIC not wrapping this. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CallIC doesn't wrap this for strict mode functions.wq 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
« src/ic.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 assertEquals(object[1], "one"); 431 assertEquals(object[1], "one");
432 assertThrows(function() { delete_element(object, "7"); }, TypeError); 432 assertThrows(function() { delete_element(object, "7"); }, TypeError);
433 assertThrows(function() { delete_element(object, 7); }, TypeError); 433 assertThrows(function() { delete_element(object, 7); }, TypeError);
434 assertEquals(object[7], "seven"); 434 assertEquals(object[7], "seven");
435 assertThrows(function() { delete_element(object, "3.14"); }, TypeError); 435 assertThrows(function() { delete_element(object, "3.14"); }, TypeError);
436 assertThrows(function() { delete_element(object, 3.14); }, TypeError); 436 assertThrows(function() { delete_element(object, 3.14); }, TypeError);
437 assertEquals(object[3.14], "pi"); 437 assertEquals(object[3.14], "pi");
438 })(); 438 })();
439 439
440 // Not transforming this in Function.call and Function.apply. 440 // Not transforming this in Function.call and Function.apply.
441 (function testThisTransform() { 441 (function testThisTransformCallApply() {
442 function non_strict() { 442 function non_strict() {
443 return this; 443 return this;
444 } 444 }
445 function strict() { 445 function strict() {
446 "use strict"; 446 "use strict";
447 return this; 447 return this;
448 } 448 }
449 449
450 var global_object = (function() { return this; })(); 450 var global_object = (function() { return this; })();
451 var object = {}; 451 var object = {};
(...skipping 19 matching lines...) Expand all
471 assertEquals(typeof strict.call("Hello"), "string"); 471 assertEquals(typeof strict.call("Hello"), "string");
472 assertTrue(strict.call(object) === object); 472 assertTrue(strict.call(object) === object);
473 473
474 // Strict apply. 474 // Strict apply.
475 assertTrue(strict.apply(null) === null); 475 assertTrue(strict.apply(null) === null);
476 assertTrue(strict.apply(undefined) === undefined); 476 assertTrue(strict.apply(undefined) === undefined);
477 assertEquals(typeof strict.apply(7), "number"); 477 assertEquals(typeof strict.apply(7), "number");
478 assertEquals(typeof strict.apply("Hello"), "string"); 478 assertEquals(typeof strict.apply("Hello"), "string");
479 assertTrue(strict.apply(object) === object); 479 assertTrue(strict.apply(object) === object);
480 })(); 480 })();
481
482 (function testThisTransform() {
483 try {
484 function strict() {
485 "use strict";
486 return typeof(this);
487 }
488 function nonstrict() {
489 return typeof(this);
490 }
491
492 // Set up fakes
493 String.prototype.strict = strict;
494 String.prototype.nonstrict = nonstrict;
495 Number.prototype.strict = strict;
496 Number.prototype.nonstrict = nonstrict;
497 Boolean.prototype.strict = strict;
498 Boolean.prototype.nonstrict = nonstrict;
499
500 function callStrict(o) {
501 return o.strict();
502 }
503 function callNonStrict(o) {
504 return o.nonstrict();
505 }
506
507 for (var i = 0; i < 10; i ++) {
508 assertEquals(("hello").strict(), "string");
509 assertEquals(("hello").nonstrict(), "object");
510 assertEquals((10 + i).strict(), "number");
511 assertEquals((10 + i).nonstrict(), "object");
512 assertEquals((true).strict(), "boolean");
513 assertEquals((true).nonstrict(), "object");
514 assertEquals((false).strict(), "boolean");
515 assertEquals((false).nonstrict(), "object");
516
517 assertEquals(callStrict("howdy"), "string");
518 assertEquals(callNonStrict("howdy"), "object");
519 assertEquals(callStrict(17 + i), "number");
520 assertEquals(callNonStrict(19 + i), "object");
521 assertEquals(callStrict(true), "boolean");
522 assertEquals(callNonStrict(true), "object");
523 assertEquals(callStrict(false), "boolean");
524 assertEquals(callNonStrict(false), "object");
525 }
526 } finally {
527 // Cleanup
528 delete String.prototype.strict;
529 delete String.prototype.nonstrict;
530 delete Number.prototype.strict;
531 delete Number.prototype.nonstrict;
532 delete Boolean.prototype.strict;
533 delete Boolean.prototype.nonstrict;
534 }
535 })();
OLDNEW
« src/ic.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698