Debian Codegraph @

js/src/tests/test262/built-ins/String/S15.5.5.1_A5.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: Once a String object is created, the length property is unchanging
6 es5id: 15.5.5.1_A5
7 description: >
8 Change valueOf and toString of String object and check length
9 property
10 ---*/
11
12 var __str__instance = new String("ABC\u0041\u0042\u0043");
13
14 //////////////////////////////////////////////////////////////////////////////
15 //CHECK#1
16 if (__str__instance.length !== 6) {
17 throw new Test262Error('#1: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.length === 6. Actual: __str__instance.length ===' + __str__instance.length);
18 }
19 //
20 //////////////////////////////////////////////////////////////////////////////
21
22 __str__instance.valueOf = function() {
23 return "ed"
24 };
25 __str__instance.toString = function() {
26 return "ed"
27 };
28
29 //////////////////////////////////////////////////////////////////////////////
30 //CHECK#2
31 if (__str__instance != "ed") {
32 throw new Test262Error('#2: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.valueOf = function(){return "ed"}; __str__instance.toString = function(){return "ed"}; __str__instance =="ed". Actual: __str__instance ==' + __str__instance);
33 }
34 //
35 //////////////////////////////////////////////////////////////////////////////
36
37 //////////////////////////////////////////////////////////////////////////////
38 //CHECK#3
39 if (__str__instance.length !== 6) {
40 throw new Test262Error('#3: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.valueOf = function(){return "ed"}; __str__instance.toString = function(){return "ed"}; __str__instance.length === 6. Actual: __str__instance.length ===' + __str__instance.length);
41 }
42 //
43 //////////////////////////////////////////////////////////////////////////////
44
45 reportCompare(0, 0);