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

Unified Diff: test/mjsunit/harmony/reflect-enumerate-special-cases.js

Issue 1397443013: [es6] Implement Reflect.enumerate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/mjsunit/harmony/reflect-enumerate-opt.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/reflect-enumerate-special-cases.js
diff --git a/test/mjsunit/for-in-special-cases.js b/test/mjsunit/harmony/reflect-enumerate-special-cases.js
similarity index 76%
copy from test/mjsunit/for-in-special-cases.js
copy to test/mjsunit/harmony/reflect-enumerate-special-cases.js
index b592ad259e90b3180c6e2949c7c45439234639dd..234a3e3e0d0171ae1da99156a244066f490e171c 100644
--- a/test/mjsunit/for-in-special-cases.js
+++ b/test/mjsunit/harmony/reflect-enumerate-special-cases.js
@@ -1,4 +1,4 @@
-// Copyright 2008 the V8 project authors. All rights reserved.
+// Copyright 2008-2015 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,47 +25,14 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --expose-gc
+// This is adapted from mjsunit/for-in-special-cases.js.
-function for_in_null() {
- try {
- for (var x in null) {
- return false;
- }
- } catch(e) {
- return false;
- }
- return true;
-}
-
-function for_in_undefined() {
- try {
- for (var x in undefined) {
- return false;
- }
- } catch(e) {
- return false;
- }
- return true;
-}
-
-for (var i = 0; i < 10; ++i) {
- assertTrue(for_in_null());
- gc();
-}
-
-for (var j = 0; j < 10; ++j) {
- assertTrue(for_in_undefined());
- gc();
-}
-
-assertEquals(10, i);
-assertEquals(10, j);
+// Flags: --harmony-reflect
function Accumulate(x) {
var accumulator = "";
- for (var i in x) {
+ for (var i of Reflect.enumerate(Object(x))) {
accumulator += i;
}
return accumulator;
@@ -73,7 +40,7 @@ function Accumulate(x) {
for (var i = 0; i < 3; ++i) {
var elements = Accumulate("abcd");
- // We do not assume that for-in enumerates elements in order.
+ // We do not assume that enumerate enumerates elements in order.
assertTrue(-1 != elements.indexOf("0"));
assertTrue(-1 != elements.indexOf("1"));
assertTrue(-1 != elements.indexOf("2"));
@@ -96,10 +63,10 @@ function for_in_string_prototype() {
var elements = Accumulate(y);
var elements1 = Accumulate(y);
- // If for-in returns elements in a different order on multiple calls, this
+ // If enumerate returns elements in a different order on multiple calls, this
// assert will fail. If that happens, consider if that behavior is OK.
- assertEquals(elements, elements1, "For-in elements not the same both times.");
- // We do not assume that for-in enumerates elements in order.
+ assertEquals(elements, elements1, "Enumeration not the same both times.");
+ // We do not assume that enumerate enumerates elements in order.
assertTrue(-1 != elements.indexOf("0"));
assertTrue(-1 != elements.indexOf("1"));
assertTrue(-1 != elements.indexOf("2"));
« no previous file with comments | « test/mjsunit/harmony/reflect-enumerate-opt.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698