]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_2/String/concat.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
24 Description: 'This tests the new String object method: concat'
27 Date: Fri Feb 13 09:58:28 PST 1998
30 var SECTION
= 'As described in Netscape doc "Whats new in JavaScript 1.2"';
31 var VERSION
= 'no version';
33 var TITLE
= 'String:concat';
35 writeHeaderToLog('Executing script: concat.js');
36 writeHeaderToLog( SECTION
+ " "+ TITLE
);
39 var testcases
= new Array();
42 var aString
= new String("test string");
43 var bString
= new String(" another ");
45 testcases
[count
++] = new TestCase( SECTION
, "aString.concat(' more')", "test string more", aString
.concat(' more').toString());
46 testcases
[count
++] = new TestCase( SECTION
, "aString.concat(bString)", "test string another ", aString
.concat(bString
).toString());
47 testcases
[count
++] = new TestCase( SECTION
, "aString ", "test string", aString
.toString());
48 testcases
[count
++] = new TestCase( SECTION
, "bString ", " another ", bString
.toString());
49 testcases
[count
++] = new TestCase( SECTION
, "aString.concat(345) ", "test string345", aString
.concat(345).toString());
50 testcases
[count
++] = new TestCase( SECTION
, "aString.concat(true) ", "test stringtrue", aString
.concat(true).toString());
51 testcases
[count
++] = new TestCase( SECTION
, "aString.concat(null) ", "test stringnull", aString
.concat(null).toString());
53 http://bugs.webkit.org/show_bug.cgi?id=11545#c3
54 According to ECMA 15.5.4.6, the argument of concat should send to ToString and
55 convert into a string value (not String object). So these arguments will be
56 convert into '' and '1,2,3' under ECMA-262v3, not the js1.2 expected '[]' and
59 //testcases[count++] = new TestCase( SECTION, "aString.concat([]) ", "test string[]", aString.concat([]).toString());
60 //testcases[count++] = new TestCase( SECTION, "aString.concat([1,2,3])", "test string[1, 2, 3]", aString.concat([1,2,3]).toString());
62 testcases
[count
++] = new TestCase( SECTION
, "'abcde'.concat(' more')", "abcde more", 'abcde'.concat(' more').toString());
63 testcases
[count
++] = new TestCase( SECTION
, "'abcde'.concat(bString)", "abcde another ", 'abcde'.concat(bString
).toString());
64 testcases
[count
++] = new TestCase( SECTION
, "'abcde' ", "abcde", 'abcde');
65 testcases
[count
++] = new TestCase( SECTION
, "'abcde'.concat(345) ", "abcde345", 'abcde'.concat(345).toString());
66 testcases
[count
++] = new TestCase( SECTION
, "'abcde'.concat(true) ", "abcdetrue", 'abcde'.concat(true).toString());
67 testcases
[count
++] = new TestCase( SECTION
, "'abcde'.concat(null) ", "abcdenull", 'abcde'.concat(null).toString());
69 http://bugs.webkit.org/show_bug.cgi?id=11545#c3
70 According to ECMA 15.5.4.6, the argument of concat should send to ToString and
71 convert into a string value (not String object). So these arguments will be
72 convert into '' and '1,2,3' under ECMA-262v3, not the js1.2 expected '[]' and
75 //testcases[count++] = new TestCase( SECTION, "'abcde'.concat([]) ", "abcde[]", 'abcde'.concat([]).toString());
76 //testcases[count++] = new TestCase( SECTION, "'abcde'.concat([1,2,3])", "abcde[1, 2, 3]", 'abcde'.concat([1,2,3]).toString());
78 //what should this do:
79 testcases
[count
++] = new TestCase( SECTION
, "'abcde'.concat() ", "abcde", 'abcde'.concat().toString());
83 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
84 testcases
[tc
].passed
= writeTestCaseResult(
87 testcases
[tc
].description
+" = "+
88 testcases
[tc
].actual
);
89 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";