blob: 1e9ad8d715bc344bff8f76784560c7dc240dc098 (
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
|
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S15.4.4.2_A2_T1;
* @section: 15.4.4.2;
* @assertion: The toString function is not generic.
* it throws a TypeError exception if its this value is not an Array object;
* @description: {}.toString = Array.prototype.toString;
*/
// Converted for Test262 from original Sputnik source
ES5Harness.registerTest( {
id: "S15.4.4.2_A2_T1",
path: "TestCases/15_Native/15.4_Array_Objects/15.4.4_Properties_of_the_Array_Prototype_Object/15.4.4.2_Array_prototype_toString/S15.4.4.2_A2_T1.js",
assertion: "The toString function is not generic.",
description: "{}.toString = Array.prototype.toString",
test: function testcase() {
var obj = {};
obj.toString = Array.prototype.toString;
//CHECK#1
try {
obj.toString();
$ERROR('#1.1: var obj = {}; obj.toString = Array.prototype.toString; obj.toString() throw TypeError. Actual: ' + (obj.toString()));
} catch(e) {
if ((e instanceof TypeError) !== true) {
$ERROR('#1.2: var obj = {}; obj.toString = Array.prototype.toString; obj.toString() throw TypeError. Actual: ' + (e));
}
}
obj[0] = 1;
obj.length = 1;
//CHECK#2
try {
obj.toString();
$ERROR('#2.1: var obj = {}; obj.toString = Array.prototype.toString; obj[0] = 1; obj.length = 1; obj.toString() throw TypeError. Actual: ' + (obj.toString()));
} catch(e) {
if ((e instanceof TypeError) !== true) {
$ERROR('#2.2: var obj = {}; obj.toString = Array.prototype.toString; obj[0] = 1; obj.length = 1; obj.toString() throw TypeError. Actual: ' + (e));
}
}
}
});
|