js/src/jit-test/tests/for-of/string-iterator-generic.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // String.prototype.iterator is generic.
     3 load(libdir + "asserts.js");
     4 load(libdir + "iteration.js");
     5 load(libdir + "string.js");
     7 function test(obj) {
     8     var it = String.prototype[std_iterator].call(obj);
     9     var s = String(obj);
    10     for (var i = 0, length = s.length; i < length;) {
    11         var r = s[i++];
    12         if (isHighSurrogate(r) && i < length && isLowSurrogate(s[i])) {
    13             r += s[i++];
    14         }
    15         assertIteratorNext(it, r);
    16     }
    17     assertIteratorDone(it, undefined);
    18 }
    20 test({toString: () => ""});
    21 test({toString: () => "xyz"});
    22 test({toString: () => "\ud808\udf45"});
    23 test({valueOf: () => ""});
    24 test({valueOf: () => "xyz"});
    25 test({valueOf: () => "\ud808\udf45"});

mercurial