summaryrefslogtreecommitdiff
path: root/test/suite/sputnik/Regression/S12.6.4_R1.js
blob: e8af3b6e9b8d4e952e98d1e714b0fb0970091f97 (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
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @name: S12.6.4_R1;
 * @section: 12.6.4, 9.9;
 * @description: The for-in statement must not throw TypeError for undefined
 * values, cause it's a bug in the Standard; 
*/

// CHECK#1
try{
  var x1 = 1;
  for(var y1 in undefined) x1 = 2;
  if (x1 === 1) {
    $PRINT("#1: passed");
  } else {
    $ERROR("#1: The for-in statement must not fullfill, the value was changed");
  }
} 
catch(e){
  if(e instanceof TypeError){
    $ERROR("#1: The for-in statement must not throw TypeError for undefined values, cause it's a bug in the Standard");
  } else {
    $ERROR("#1: The for-in statement must not throw Error for undefined values, cause it's a bug in the Standard");
  }
}

// CHECK#2
try{
  var x2 = 1;
  for(var y2 in this.foo) x2 = 2;
  if (x2 === 1) {
    $PRINT("#1: passed");
  } else {
    $ERROR("#1: The for-in statement must not fullfill, the value was changed");
  }
} 
catch(e){
  if(e instanceof TypeError){
    $ERROR("#1: The for-in statement must not throw TypeError for undefined values, cause it's a bug in the Standard");
  } else {
    $ERROR("#1: The for-in statement must not throw Error for undefined values, cause it's a bug in the Standard");
  }
}