Home | History | Annotate | Download | only in regress
      1 // Copyright 2010 the V8 project authors. All rights reserved.
      2 // Redistribution and use in source and binary forms, with or without
      3 // modification, are permitted provided that the following conditions are
      4 // met:
      5 //
      6 //     * Redistributions of source code must retain the above copyright
      7 //       notice, this list of conditions and the following disclaimer.
      8 //     * Redistributions in binary form must reproduce the above
      9 //       copyright notice, this list of conditions and the following
     10 //       disclaimer in the documentation and/or other materials provided
     11 //       with the distribution.
     12 //     * Neither the name of Google Inc. nor the names of its
     13 //       contributors may be used to endorse or promote products derived
     14 //       from this software without specific prior written permission.
     15 //
     16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 function props(x) {
     29   var result = [];
     30   for (var p in x) result.push(p);
     31   return result;
     32 }
     33 
     34 function A() {
     35   this.a1 = 1234;
     36   this.a2 = "D";
     37   this.a3 = false;
     38 }
     39 
     40 function B() {
     41   this.b3 = false;
     42   this.b2 = "D";
     43   this.b1 = 1234;
     44 }
     45 
     46 function C() {
     47   this.c3 = false;
     48   this.c1 = 1234;
     49   this.c2 = "D";
     50 }
     51 
     52 assertArrayEquals(["a1", "a2", "a3"], props(new A()));
     53 assertArrayEquals(["b3", "b2", "b1"], props(new B()));
     54 assertArrayEquals(["c3", "c1", "c2"], props(new C()));
     55 assertArrayEquals(["s1", "s2", "s3"], props({s1: 0, s2: 0, s3: 0}));
     56 assertArrayEquals(["s3", "s2", "s1"], props({s3: 0, s2: 0, s1: 0}));
     57 assertArrayEquals(["s3", "s1", "s2"], props({s3: 0, s1: 0, s2: 0}));
     58 
     59 var a = new A()
     60 a.a0 = 0;
     61 a.a4 = 0;
     62 assertArrayEquals(["a1", "a2", "a3", "a0", "a4"], props(a));
     63 
     64 var b = new B()
     65 b.b4 = 0;
     66 b.b0 = 0;
     67 assertArrayEquals(["b3", "b2", "b1", "b4", "b0"], props(b));
     68 
     69 var o1 = {s1: 0, s2: 0, s3: 0}
     70 o1.s0 = 0;
     71 o1.s4 = 0;
     72 assertArrayEquals(["s1", "s2", "s3", "s0", "s4"], props(o1));
     73 
     74 var o2 = {s3: 0, s2: 0, s1: 0}
     75 o2.s4 = 0;
     76 o2.s0 = 0;
     77 assertArrayEquals(["s3", "s2", "s1", "s4", "s0"], props(o2));
     78