]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/SourceText/6-1.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / 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/
5 *
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.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
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
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22 /**
23 File Name: 6-1.js
24 ECMA Section: Source Text
25 Description:
26
27 ECMAScript source text is represented as a sequence of characters
28 representable using the Unicode version 2.0 character encoding.
29
30 SourceCharacter ::
31 any Unicode character
32
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
41 value of the literal.
42
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.
58
59 Author: christine@netscape.com
60 Date: 12 november 1997
61 */
62
63 var SECTION = "6-1";
64 var VERSION = "ECMA_1";
65 startTest();
66 var TITLE = "Source Text";
67
68 writeHeaderToLog( SECTION + " "+ TITLE);
69
70 var testcases = new Array();
71
72 testcases[tc] = new TestCase( SECTION,
73 "// the following character should not be interpreted as a line terminator in a comment: \u000A",
74 'PASSED',
75 "PASSED" );
76
77 // \u000A testcases[tc].actual = "FAILED!";
78
79 tc++;
80
81 testcases[tc] = new TestCase( SECTION,
82 "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'",
83 'PASSED',
84 'PASSED' );
85
86 // the following character should noy be interpreted as a line terminator: \\n testcases[tc].actual = "FAILED"
87
88 tc++;
89
90 testcases[tc] = new TestCase( SECTION,
91 "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'",
92 'PASSED',
93 'PASSED' )
94
95 // the following character should not be interpreted as a line terminator: \u000A testcases[tc].actual = "FAILED"
96
97 testcases[tc++] = new TestCase( SECTION,
98 "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'",
99 'PASSED',
100 'PASSED' )
101 // the following character should not be interpreted as a line terminator: \n testcases[tc].actual = 'FAILED'
102
103 testcases[tc] = new TestCase( SECTION,
104 "// the following character should not be interpreted as a line terminator in a comment: u000D",
105 'PASSED',
106 'PASSED' )
107
108 // the following character should not be interpreted as a line terminator: \u000D testcases[tc].actual = "FAILED"
109
110 test();
111
112 function test() {
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 );
119
120 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
121 }
122 stopTest();
123 return ( testcases );
124 }