1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
42 ECMA Section: Source Text
45 ECMAScript source text is represented as a sequence of characters
46 representable using the Unicode version 2.0 character encoding.
51 However, it is possible to represent every ECMAScript program using
52 only ASCII characters (which are equivalent to the first 128 Unicode
53 characters). Non-ASCII Unicode characters may appear only within comments
54 and string literals. In string literals, any Unicode character may also be
55 expressed as a Unicode escape sequence consisting of six ASCII characters,
56 namely \u plus four hexadecimal digits. Within a comment, such an escape
57 sequence is effectively ignored as part of the comment. Within a string
58 literal, the Unicode escape sequence contributes one character to the string
61 Note that ECMAScript differs from the Java programming language in the
62 behavior of Unicode escape sequences. In a Java program, if the Unicode escape
63 sequence \u000A, for example, occurs within a single-line comment, it is
64 interpreted as a line terminator (Unicode character 000A is line feed) and
65 therefore the next character is not part of the comment. Similarly, if the
66 Unicode escape sequence \u000A occurs within a string literal in a Java
67 program, it is likewise interpreted as a line terminator, which is not
68 allowed within a string literal-one must write \n instead of \u000A to
69 cause a line feed to be part of the string value of a string literal. In
70 an ECMAScript program, a Unicode escape sequence occurring within a comment
71 is never interpreted and therefore cannot contribute to termination of the
72 comment. Similarly, a Unicode escape sequence occurring within a string literal
73 in an ECMAScript program always contributes a character to the string value of
74 the literal and is never interpreted as a line terminator or as a quote mark
75 that might terminate the string literal.
77 Author: christine@netscape.com
78 Date: 12 november 1997
82 var VERSION = "ECMA_1";
84 var TITLE = "Source Text";
86 writeHeaderToLog( SECTION + " "+ TITLE);
88 var testcase = new TestCase( SECTION,
89 "// the following character should not be interpreted as a line terminator in a comment: \u000A",
93 // \u000A testcase.actual = "FAILED!";
96 new TestCase( SECTION,
97 "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'",
101 // the following character should noy be interpreted as a line terminator: \\n testcase.actual = "FAILED"
104 new TestCase( SECTION,
105 "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'",
109 // the following character should not be interpreted as a line terminator: \u000A testcase.actual = "FAILED"
112 new TestCase( SECTION,
113 "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'",
116 // the following character should not be interpreted as a line terminator: \n testcase.actual = 'FAILED'
119 new TestCase( SECTION,
120 "// the following character should not be interpreted as a line terminator in a comment: u000D",
124 // the following character should not be interpreted as a line terminator: \u000D testcase.actual = "FAILED"