]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/SourceText/6-1.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 ECMA Section: Source Text
27 ECMAScript source text is represented as a sequence of characters
28 representable using the Unicode version 2.0 character encoding.
33 However, it is possible to represent every ECMAScript program using
34 only ASCII characters (which are equivalent to the first 128 Unicode
35 characters). Non-ASCII Unicode characters may appear only within comments
36 and string literals. In string literals, any Unicode character may also be
37 expressed as a Unicode escape sequence consisting of six ASCII characters,
38 namely \u plus four hexadecimal digits. Within a comment, such an escape
39 sequence is effectively ignored as part of the comment. Within a string
40 literal, the Unicode escape sequence contributes one character to the string
43 Note that ECMAScript differs from the Java programming language in the
44 behavior of Unicode escape sequences. In a Java program, if the Unicode escape
45 sequence \u000A, for example, occurs within a single-line comment, it is
46 interpreted as a line terminator (Unicode character 000A is line feed) and
47 therefore the next character is not part of the comment. Similarly, if the
48 Unicode escape sequence \u000A occurs within a string literal in a Java
49 program, it is likewise interpreted as a line terminator, which is not
50 allowed within a string literal-one must write \n instead of \u000A to
51 cause a line feed to be part of the string value of a string literal. In
52 an ECMAScript program, a Unicode escape sequence occurring within a comment
53 is never interpreted and therefore cannot contribute to termination of the
54 comment. Similarly, a Unicode escape sequence occurring within a string literal
55 in an ECMAScript program always contributes a character to the string value of
56 the literal and is never interpreted as a line terminator or as a quote mark
57 that might terminate the string literal.
59 Author: christine@netscape.com
60 Date: 12 november 1997
64 var VERSION
= "ECMA_1";
66 var TITLE
= "Source Text";
68 writeHeaderToLog( SECTION
+ " "+ TITLE
);
70 var testcases
= new Array();
72 testcases
[tc
] = new TestCase( SECTION
,
73 "// the following character should not be interpreted as a line terminator in a comment: \u000A",
77 // \u000A testcases[tc].actual = "FAILED!";
81 testcases
[tc
] = new TestCase( SECTION
,
82 "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'",
86 // the following character should noy be interpreted as a line terminator: \\n testcases[tc].actual = "FAILED"
90 testcases
[tc
] = new TestCase( SECTION
,
91 "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'",
95 // the following character should not be interpreted as a line terminator: \u000A testcases[tc].actual = "FAILED"
97 testcases
[tc
++] = new TestCase( SECTION
,
98 "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'",
101 // the following character should not be interpreted as a line terminator: \n testcases[tc].actual = 'FAILED'
103 testcases
[tc
] = new TestCase( SECTION
,
104 "// the following character should not be interpreted as a line terminator in a comment: u000D",
108 // the following character should not be interpreted as a line terminator: \u000D testcases[tc].actual = "FAILED"
113 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
114 testcases
[tc
].passed
= writeTestCaseResult(
115 testcases
[tc
].expect
,
116 testcases
[tc
].actual
,
117 testcases
[tc
].description
+" = "+
118 testcases
[tc
].actual
);
120 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
123 return ( testcases
);