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

Side by Side Diff: src/array.js

Issue 546032: Enabled es5conform tests for new array methods and corrected errors that was ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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 | « no previous file | src/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return result; 912 return result;
913 } 913 }
914 914
915 915
916 function ArrayForEach(f, receiver) { 916 function ArrayForEach(f, receiver) {
917 if (!IS_FUNCTION(f)) { 917 if (!IS_FUNCTION(f)) {
918 throw MakeTypeError('called_non_callable', [ f ]); 918 throw MakeTypeError('called_non_callable', [ f ]);
919 } 919 }
920 // Pull out the length so that modifications to the length in the 920 // Pull out the length so that modifications to the length in the
921 // loop will not affect the looping. 921 // loop will not affect the looping.
922 var length = this.length; 922 var length = TO_UINT32(this.length);
923 for (var i = 0; i < length; i++) { 923 for (var i = 0; i < length; i++) {
924 var current = this[i]; 924 var current = this[i];
925 if (!IS_UNDEFINED(current) || i in this) { 925 if (!IS_UNDEFINED(current) || i in this) {
926 f.call(receiver, current, i, this); 926 f.call(receiver, current, i, this);
927 } 927 }
928 } 928 }
929 } 929 }
930 930
931 931
932 // Executes the function once for each element present in the 932 // Executes the function once for each element present in the
933 // array until it finds one where callback returns true. 933 // array until it finds one where callback returns true.
934 function ArraySome(f, receiver) { 934 function ArraySome(f, receiver) {
935 if (!IS_FUNCTION(f)) { 935 if (!IS_FUNCTION(f)) {
936 throw MakeTypeError('called_non_callable', [ f ]); 936 throw MakeTypeError('called_non_callable', [ f ]);
937 } 937 }
938 // Pull out the length so that modifications to the length in the 938 // Pull out the length so that modifications to the length in the
939 // loop will not affect the looping. 939 // loop will not affect the looping.
940 var length = this.length; 940 var length = TO_UINT32(this.length);
941 for (var i = 0; i < length; i++) { 941 for (var i = 0; i < length; i++) {
942 var current = this[i]; 942 var current = this[i];
943 if (!IS_UNDEFINED(current) || i in this) { 943 if (!IS_UNDEFINED(current) || i in this) {
944 if (f.call(receiver, current, i, this)) return true; 944 if (f.call(receiver, current, i, this)) return true;
945 } 945 }
946 } 946 }
947 return false; 947 return false;
948 } 948 }
949 949
950 950
951 function ArrayEvery(f, receiver) { 951 function ArrayEvery(f, receiver) {
952 if (!IS_FUNCTION(f)) { 952 if (!IS_FUNCTION(f)) {
953 throw MakeTypeError('called_non_callable', [ f ]); 953 throw MakeTypeError('called_non_callable', [ f ]);
954 } 954 }
955 // Pull out the length so that modifications to the length in the 955 // Pull out the length so that modifications to the length in the
956 // loop will not affect the looping. 956 // loop will not affect the looping.
957 var length = this.length; 957 var length = TO_UINT32(this.length);
958 for (var i = 0; i < length; i++) { 958 for (var i = 0; i < length; i++) {
959 var current = this[i]; 959 var current = this[i];
960 if (!IS_UNDEFINED(current) || i in this) { 960 if (!IS_UNDEFINED(current) || i in this) {
961 if (!f.call(receiver, current, i, this)) return false; 961 if (!f.call(receiver, current, i, this)) return false;
962 } 962 }
963 } 963 }
964
965 return true; 964 return true;
966 } 965 }
967 966
968
969 function ArrayMap(f, receiver) { 967 function ArrayMap(f, receiver) {
970 if (!IS_FUNCTION(f)) { 968 if (!IS_FUNCTION(f)) {
971 throw MakeTypeError('called_non_callable', [ f ]); 969 throw MakeTypeError('called_non_callable', [ f ]);
972 } 970 }
973 // Pull out the length so that modifications to the length in the 971 // Pull out the length so that modifications to the length in the
974 // loop will not affect the looping. 972 // loop will not affect the looping.
975 var length = this.length; 973 var length = TO_UINT32(this.length);
976 var result = new $Array(length); 974 var result = new $Array(length);
977 for (var i = 0; i < length; i++) { 975 for (var i = 0; i < length; i++) {
978 var current = this[i]; 976 var current = this[i];
979 if (!IS_UNDEFINED(current) || i in this) { 977 if (!IS_UNDEFINED(current) || i in this) {
980 result[i] = f.call(receiver, current, i, this); 978 result[i] = f.call(receiver, current, i, this);
981 } 979 }
982 } 980 }
983 return result; 981 return result;
984 } 982 }
985 983
986 984
987 function ArrayIndexOf(element, index) { 985 function ArrayIndexOf(element, index) {
986 if (IS_UNDEFINED(element)) {
987 throw MakeTypeError('array_indexof_not_defined', [element]);
988 }
988 var length = this.length; 989 var length = this.length;
989 if (index == null) { 990 if (index == null) {
990 index = 0; 991 index = 0;
991 } else { 992 } else {
992 index = TO_INTEGER(index); 993 index = TO_INTEGER(index);
993 // If index is negative, index from the end of the array. 994 // If index is negative, index from the end of the array.
994 if (index < 0) index = length + index; 995 if (index < 0) index = length + index;
995 // If index is still negative, search the entire array. 996 // If index is still negative, search the entire array.
996 if (index < 0) index = 0; 997 if (index < 0) index = 0;
997 } 998 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 ArrayIndexOf: 1, 1148 ArrayIndexOf: 1,
1148 ArrayLastIndexOf: 1, 1149 ArrayLastIndexOf: 1,
1149 ArrayPush: 1, 1150 ArrayPush: 1,
1150 ArrayReduce: 1, 1151 ArrayReduce: 1,
1151 ArrayReduceRight: 1 1152 ArrayReduceRight: 1
1152 }); 1153 });
1153 } 1154 }
1154 1155
1155 1156
1156 SetupArray(); 1157 SetupArray();
OLDNEW
« no previous file with comments | « no previous file | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698