js/src/tests/ecma/SourceText/6-1.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /**
     8    File Name:          6-1.js
     9    ECMA Section:       Source Text
    10    Description:
    12    ECMAScript source text is represented as a sequence of characters
    13    representable using the Unicode version 2.0 character encoding.
    15    SourceCharacter ::
    16    any Unicode character
    18    However, it is possible to represent every ECMAScript program using
    19    only ASCII characters (which are equivalent to the first 128 Unicode
    20    characters). Non-ASCII Unicode characters may appear only within comments
    21    and string literals. In string literals, any Unicode character may also be
    22    expressed as a Unicode escape sequence consisting of six ASCII characters,
    23    namely \u plus four hexadecimal digits. Within a comment, such an escape
    24    sequence is effectively ignored as part of the comment. Within a string
    25    literal, the Unicode escape sequence contributes one character to the string
    26    value of the literal.
    28    Note that ECMAScript differs from the Java programming language in the
    29    behavior of Unicode escape sequences. In a Java program, if the Unicode escape
    30    sequence \u000A, for example, occurs within a single-line comment, it is
    31    interpreted as a line terminator (Unicode character 000A is line feed) and
    32    therefore the next character is not part of the comment. Similarly, if the
    33    Unicode escape sequence \u000A occurs within a string literal in a Java
    34    program, it is likewise interpreted as a line terminator, which is not
    35    allowed within a string literal-one must write \n instead of \u000A to
    36    cause a line feed to be part of the string value of a string literal. In
    37    an ECMAScript program, a Unicode escape sequence occurring within a comment
    38    is never interpreted and therefore cannot contribute to termination of the
    39    comment. Similarly, a Unicode escape sequence occurring within a string literal
    40    in an ECMAScript program always contributes a character to the string value of
    41    the literal and is never interpreted as a line terminator or as a quote mark
    42    that might terminate the string literal.
    44    Author:             christine@netscape.com
    45    Date:               12 november 1997
    46 */
    48 var SECTION = "6-1";
    49 var VERSION = "ECMA_1";
    50 startTest();
    51 var TITLE   = "Source Text";
    53 writeHeaderToLog( SECTION + " "+ TITLE);
    55 var testcase = new TestCase( SECTION,
    56 			     "// the following character should not be interpreted as a line terminator in a comment: \u000A",
    57 			     'PASSED',
    58 			     "PASSED" );
    60 // \u000A testcase.actual = "FAILED!";
    62 testcase =
    63   new TestCase( SECTION,
    64 		"// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'",
    65 		'PASSED',
    66 		'PASSED' );
    68 // the following character should noy be interpreted as a line terminator: \\n testcase.actual = "FAILED"
    70 testcase =
    71   new TestCase( SECTION,
    72 		"// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'",
    73 		'PASSED',
    74 		'PASSED' );
    76 // the following character should not be interpreted as a line terminator:   \u000A testcase.actual = "FAILED"
    78 testcase =
    79   new TestCase( SECTION,
    80 		"// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'",
    81 		'PASSED',
    82 		'PASSED' );
    83 // the following character should not be interpreted as a line terminator: \n testcase.actual = 'FAILED'
    85 testcase =
    86   new TestCase(   SECTION,
    87 		  "// the following character should not be interpreted as a line terminator in a comment: u000D",
    88 		  'PASSED',
    89 		  'PASSED' );
    91 // the following character should not be interpreted as a line terminator:   \u000D testcase.actual = "FAILED"
    93 test();

mercurial