aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/sputnik_converted/15_Native/15.4_Array_Objects/15.4.5_Properties_of_Array_Instances/15.4.5.2_length/S15.4.5.2_A3_T2.js
blob: 9d8f5d124505ec1fca6acbedd69e6a045649024c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @name: S15.4.5.2_A3_T2;
 * @section: 15.4.5.2, 15.4;
 * @assertion: If the length property is changed, every property whose name 
 * is an array index whose value is not smaller than the new length is automatically deleted;
 * @description: If new length greater than the name of every property whose name 
 * is an array index;
*/


// Converted for Test262 from original Sputnik source

ES5Harness.registerTest( {
id: "S15.4.5.2_A3_T2",

path: "TestCases/15_Native/15.4_Array_Objects/15.4.5_Properties_of_Array_Instances/15.4.5.2_length/S15.4.5.2_A3_T2.js",

assertion: "If the length property is changed, every property whose name",

description: "If new length greater than the name of every property whose name",

test: function testcase() {
   //CHECK#1
var x = [];
x[1] = 1;
x[3] = 3;
x[5] = 5;
x.length = 4;
if (x.length !== 4) {  
  $ERROR('#1: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length === 4. Actual: ' + (x.length));    
}

//CHECK#2
if (x[5] !== undefined) {      
  $ERROR('#2: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[5] === undefined. Actual: ' + (x[5]));
}

//CHECK#3
if (x[3] !== 3) {      
  $ERROR('#3: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[3] === 3. Actual: ' + (x[3]));
}

//CHECK#4
x.length = new Number(6);
if (x[5] !== undefined) {      
  $ERROR('#4: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x[5] === undefined. Actual: ' + (x[5]));
}

//CHECK#5
x.length = 0;
if (x[0] !== undefined) {      
  $ERROR('#5: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x[0] === undefined. Actual: ' + (x[0]));
}

//CHECK#6
x.length = 1;
if (x[1] !== undefined) {      
  $ERROR('#6: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x.length = 1; x[1] === undefined. Actual: ' + (x[1]));
}

 }
});