summaryrefslogtreecommitdiff
path: root/test/suite/sputnik/Conformance/15_Native/15.11_Error_Objects/15.11.4_Properties_of_the_Error_Prototype_Object/S15.11.4.1_A1_T2.js
blob: 695826b41d6d0117d10e07f0981b5c8ed419043f (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
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
* @name: S15.11.4.1_A1_T2;
* @section: 15.11.4.1, 16;
* @assertion: The initial value of Error.prototype.constructor is the built-in Error constructor;
* @description: Checking if creating "new Error.prototype.constructor" passes and checking its properties;
*/

constr = Error.prototype.constructor;

err = new constr;

//////////////////////////////////////////////////////////////////////////////
// CHECK#0
if (err === undefined) {
	$ERROR('#0: constr = Error.prototype.constructor; err = new constr; err === undefined');
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// CHECK#1
if (err.constructor !== Error) {
	$ERROR('#1: constr = Error.prototype.constructor; err = new constr; err.constructor === Error. Actual: '+err.constructor );
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// CHECK#2
if (!(Error.prototype.isPrototypeOf(err))) {
	$ERROR('#2: constr = Error.prototype.constructor; err = new constr; Error.prototype.isPrototypeOf(err) return true. Actual: '+Error.prototype.isPrototypeOf(err));
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// CHECK#3
Error.prototype.toString=Object.prototype.toString;
to_string_result = '[object '+ 'Error' +']';
if (err.toString() !== to_string_result) {
	$ERROR('#3: constr = Error.prototype.constructor; err = new constr; Error.prototype.toString=Object.prototype.toString; err.toString() === \'[object Error]\'. Actual: '+err.toString() );
}
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// CHECK#4
if (err.valueOf().toString() !== to_string_result) {
	$ERROR('#4: constr = Error.prototype.constructor; err = new constr; Error.prototype.toString=Object.prototype.toString; err.valueOf().toString() === \'[object Error]\'. Actual: '+err.valueOf().toString() );
}
//
//////////////////////////////////////////////////////////////////////////////