tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

basic-for-each.js (1355B)


      1 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 //-----------------------------------------------------------------------------
      7 var BUGNUMBER     = "346582";
      8 var summary = "Basic support for iterable objects and for-each";
      9 var actual, expect;
     10 
     11 printBugNumber(BUGNUMBER);
     12 printStatus(summary);
     13 
     14 /**************
     15 * BEGIN TEST *
     16 **************/
     17 
     18 var failed = false;
     19 
     20 var iterable = { persistedProp: 17 };
     21 
     22 function Array_equals(a, b)
     23 {
     24  if (!(a instanceof Array) || !(b instanceof Array))
     25    throw new Error("Arguments not both of type Array");
     26  if (a.length != b.length)
     27    return false;
     28  for (var i = 0, sz = a.length; i < sz; i++)
     29    if (a[i] !== b[i])
     30      return false;
     31  return true;
     32 }
     33 
     34 try
     35 {
     36  // nothing unusual so far -- verify basic properties
     37  for (var i in iterable)
     38  {
     39    if (i != "persistedProp")
     40      throw "no persistedProp!";
     41    if (iterable[i] != 17)
     42      throw "iterable[\"persistedProp\"] == 17";
     43  }
     44 
     45  if (iterable.persistedProp != 17)
     46    throw "iterable.persistedProp not persisted!";
     47 }
     48 catch (e)
     49 {
     50  failed = e;
     51 }
     52 
     53 
     54 
     55 expect = false;
     56 actual = failed;
     57 
     58 reportCompare(expect, actual, summary);