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

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

Issue 6613005: Implementation of strict mode in SetElement. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: SetElement in strict mode. Created 9 years, 9 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/handles.cc ('K') | « test/cctest/test-heap.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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 test(o, 5, 17); // start specialized for smi indices 821 test(o, 5, 17); // start specialized for smi indices
822 assertEquals(o[5], 17); 822 assertEquals(o[5], 17);
823 test(o, "a", 19); 823 test(o, "a", 19);
824 assertEquals(o["a"], 19); 824 assertEquals(o["a"], 19);
825 test(o, "5", 29); 825 test(o, "5", 29);
826 assertEquals(o[5], 29); 826 assertEquals(o[5], 29);
827 test(o, 100000, 31); 827 test(o, 100000, 31);
828 assertEquals(o[100000], 31); 828 assertEquals(o[100000], 31);
829 } 829 }
830 })(); 830 })();
831
832
833 (function TestSetElementWithoutSetter() {
834 "use strict";
835
836 var o = { };
837 Object.defineProperty(o, 0, { get : function() { } });
838
839 var zero_smi = 0;
840 var zero_number = new Number(0);
841 var zero_symbol = "0";
842 var zero_string = "-0-".substring(1,2);
843
844 assertThrows(function() { o[zero_smi] = "new value"; }, TypeError);
845 assertThrows(function() { o[zero_number] = "new value"; }, TypeError);
846 assertThrows(function() { o[zero_symbol] = "new value"; }, TypeError);
847 assertThrows(function() { o[zero_string] = "new value"; }, TypeError);
848 })();
849
850
851 (function TestSetElementNonConfigurable() {
852 "use strict";
853 var frozen = Object.freeze({});
854 var sealed = Object.seal({});
855
856 var zero_number = 0;
857 var zero_symbol = "0";
858 var zero_string = "-0-".substring(1,2);
859
860 assertThrows(function() { frozen[zero_number] = "value"; }, TypeError);
861 assertThrows(function() { sealed[zero_number] = "value"; }, TypeError);
862 assertThrows(function() { frozen[zero_symbol] = "value"; }, TypeError);
863 assertThrows(function() { sealed[zero_symbol] = "value"; }, TypeError);
864 assertThrows(function() { frozen[zero_string] = "value"; }, TypeError);
865 assertThrows(function() { sealed[zero_string] = "value"; }, TypeError);
866 })();
867
868
869 (function TestAssignmentToReadOnlyElement() {
870 "use strict";
871
872 var o = {};
873 Object.defineProperty(o, 7, { value: 17 });
874
875 var seven_smi = 7;
876 var seven_number = new Number(7);
877 var seven_symbol = "7";
878 var seven_string = "-7-".substring(1,2);
879
880 // Index with number.
881 assertThrows(function() { o[seven_smi] = "value"; }, TypeError);
882 assertThrows(function() { o[seven_smi] += 10; }, TypeError);
883 assertThrows(function() { o[seven_smi] -= 10; }, TypeError);
884 assertThrows(function() { o[seven_smi] *= 10; }, TypeError);
885 assertThrows(function() { o[seven_smi] /= 10; }, TypeError);
886 assertThrows(function() { o[seven_smi]++; }, TypeError);
887 assertThrows(function() { o[seven_smi]--; }, TypeError);
888 assertThrows(function() { ++o[seven_smi]; }, TypeError);
889 assertThrows(function() { --o[seven_smi]; }, TypeError);
890
891 assertThrows(function() { o[seven_number] = "value"; }, TypeError);
892 assertThrows(function() { o[seven_number] += 10; }, TypeError);
893 assertThrows(function() { o[seven_number] -= 10; }, TypeError);
894 assertThrows(function() { o[seven_number] *= 10; }, TypeError);
895 assertThrows(function() { o[seven_number] /= 10; }, TypeError);
896 assertThrows(function() { o[seven_number]++; }, TypeError);
897 assertThrows(function() { o[seven_number]--; }, TypeError);
898 assertThrows(function() { ++o[seven_number]; }, TypeError);
899 assertThrows(function() { --o[seven_number]; }, TypeError);
900
901 assertThrows(function() { o[seven_symbol] = "value"; }, TypeError);
902 assertThrows(function() { o[seven_symbol] += 10; }, TypeError);
903 assertThrows(function() { o[seven_symbol] -= 10; }, TypeError);
904 assertThrows(function() { o[seven_symbol] *= 10; }, TypeError);
905 assertThrows(function() { o[seven_symbol] /= 10; }, TypeError);
906 assertThrows(function() { o[seven_symbol]++; }, TypeError);
907 assertThrows(function() { o[seven_symbol]--; }, TypeError);
908 assertThrows(function() { ++o[seven_symbol]; }, TypeError);
909 assertThrows(function() { --o[seven_symbol]; }, TypeError);
910
911 assertThrows(function() { o[seven_string] = "value"; }, TypeError);
912 assertThrows(function() { o[seven_string] += 10; }, TypeError);
913 assertThrows(function() { o[seven_string] -= 10; }, TypeError);
914 assertThrows(function() { o[seven_string] *= 10; }, TypeError);
915 assertThrows(function() { o[seven_string] /= 10; }, TypeError);
916 assertThrows(function() { o[seven_string]++; }, TypeError);
917 assertThrows(function() { o[seven_string]--; }, TypeError);
918 assertThrows(function() { ++o[seven_string]; }, TypeError);
919 assertThrows(function() { --o[seven_string]; }, TypeError);
920
921 assertEquals(o[seven_number], 17);
922 assertEquals(o[seven_symbol], 17);
923 assertEquals(o[seven_string], 17);
924 })();
925
926
927 (function TestAssignmentToReadOnlyLoop() {
928 "use strict";
929
930 var o = {};
931 Object.defineProperty(o, 7, { value: 17 });
932
933 var seven_smi = 7;
934 var seven_number = new Number(7);
935 var seven_symbol = "7";
936 var seven_string = "-7-".substring(1,2);
937
938 for (var i = 0; i < 10; i ++) {
939 assertThrows(function() { o[seven_smi] = "value" }, TypeError);
940 assertThrows(function() { o[seven_number] = "value" }, TypeError);
941 assertThrows(function() { o[seven_symbol] = "value" }, TypeError);
942 assertThrows(function() { o[seven_string] = "value" }, TypeError);
943 }
944
945 assertEquals(o[7], 17);
946 })();
OLDNEW
« src/handles.cc ('K') | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698