Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma / SourceText / 6-1.js
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
4  *
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/
9  *
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
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
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.
22  *
23  * Contributor(s):
24  *
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.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39
40 /**
41    File Name:          6-1.js
42    ECMA Section:       Source Text
43    Description:
44
45    ECMAScript source text is represented as a sequence of characters
46    representable using the Unicode version 2.0 character encoding.
47
48    SourceCharacter ::
49    any Unicode character
50
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
59    value of the literal.
60
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.
76
77    Author:             christine@netscape.com
78    Date:               12 november 1997
79 */
80
81 var SECTION = "6-1";
82 var VERSION = "ECMA_1";
83 startTest();
84 var TITLE   = "Source Text";
85
86 writeHeaderToLog( SECTION + " "+ TITLE);
87
88 var testcase = new TestCase( SECTION,
89                              "// the following character should not be interpreted as a line terminator in a comment: \u000A",
90                              'PASSED',
91                              "PASSED" );
92
93 // \u000A testcase.actual = "FAILED!";
94
95 testcase =
96   new TestCase( SECTION,
97                 "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'",
98                 'PASSED',
99                 'PASSED' );
100
101 // the following character should noy be interpreted as a line terminator: \\n testcase.actual = "FAILED"
102
103 testcase =
104   new TestCase( SECTION,
105                 "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'",
106                 'PASSED',
107                 'PASSED' );
108
109 // the following character should not be interpreted as a line terminator:   \u000A testcase.actual = "FAILED"
110
111 testcase =
112   new TestCase( SECTION,
113                 "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'",
114                 'PASSED',
115                 'PASSED' );
116 // the following character should not be interpreted as a line terminator: \n testcase.actual = 'FAILED'
117
118 testcase =
119   new TestCase(   SECTION,
120                   "// the following character should not be interpreted as a line terminator in a comment: u000D",
121                   'PASSED',
122                   'PASSED' );
123
124 // the following character should not be interpreted as a line terminator:   \u000D testcase.actual = "FAILED"
125
126 test();
127