summaryrefslogtreecommitdiff
path: root/test/built-ins/Error/S15.11.2.1_A1_T1.js
blob: 804116b32c773e9a4fda9e7e924429f98a47ba29 (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
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
    If the argument "message" is not undefined, the message property of the newly constructed object is
    set to ToString(message)
es5id: 15.11.2.1_A1_T1
description: Checking message property of different error objects
---*/

function otherScope(msg)
{
  return new Error(msg);
}

//////////////////////////////////////////////////////////////////////////////
//CHECK#1
var err1 = new Error('msg1');
if (err1.message !== "msg1") {
  $ERROR('#1: var err1=new Error(\'msg1\'); err1.message==="msg1". Actual: ' + err1.message);
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//CHECK#2
var err2 = otherScope('msg2');
if (err2.message !== "msg2") {
  $ERROR('#2: function otherScope(msg){return new Error(msg);} var err2=otherScope(\'msg2\'); err2.message==="msg2". Actual: ' + err2.message);
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//CHECK#3
var err3 = otherScope();
if (err3.hasOwnProperty('message')) {
  $ERROR('#3: function otherScope(msg){return new Error(msg);} var err3=otherScope(); err3.hasOwnProperty("message"). Actual: ' + err3.message);
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//CHECK#4
var err4 = eval("new Error('msg4')");
if (err4.message !== "msg4") {
  $ERROR('#4: var err4=eval("new Error(\'msg4\')"); err4.message==="msg4". Actual: ' + err4.message);
}
//
//////////////////////////////////////////////////////////////////////////////