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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/SourceText/6-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          6-1.js
    1.12 +   ECMA Section:       Source Text
    1.13 +   Description:
    1.14 +
    1.15 +   ECMAScript source text is represented as a sequence of characters
    1.16 +   representable using the Unicode version 2.0 character encoding.
    1.17 +
    1.18 +   SourceCharacter ::
    1.19 +   any Unicode character
    1.20 +
    1.21 +   However, it is possible to represent every ECMAScript program using
    1.22 +   only ASCII characters (which are equivalent to the first 128 Unicode
    1.23 +   characters). Non-ASCII Unicode characters may appear only within comments
    1.24 +   and string literals. In string literals, any Unicode character may also be
    1.25 +   expressed as a Unicode escape sequence consisting of six ASCII characters,
    1.26 +   namely \u plus four hexadecimal digits. Within a comment, such an escape
    1.27 +   sequence is effectively ignored as part of the comment. Within a string
    1.28 +   literal, the Unicode escape sequence contributes one character to the string
    1.29 +   value of the literal.
    1.30 +
    1.31 +   Note that ECMAScript differs from the Java programming language in the
    1.32 +   behavior of Unicode escape sequences. In a Java program, if the Unicode escape
    1.33 +   sequence \u000A, for example, occurs within a single-line comment, it is
    1.34 +   interpreted as a line terminator (Unicode character 000A is line feed) and
    1.35 +   therefore the next character is not part of the comment. Similarly, if the
    1.36 +   Unicode escape sequence \u000A occurs within a string literal in a Java
    1.37 +   program, it is likewise interpreted as a line terminator, which is not
    1.38 +   allowed within a string literal-one must write \n instead of \u000A to
    1.39 +   cause a line feed to be part of the string value of a string literal. In
    1.40 +   an ECMAScript program, a Unicode escape sequence occurring within a comment
    1.41 +   is never interpreted and therefore cannot contribute to termination of the
    1.42 +   comment. Similarly, a Unicode escape sequence occurring within a string literal
    1.43 +   in an ECMAScript program always contributes a character to the string value of
    1.44 +   the literal and is never interpreted as a line terminator or as a quote mark
    1.45 +   that might terminate the string literal.
    1.46 +
    1.47 +   Author:             christine@netscape.com
    1.48 +   Date:               12 november 1997
    1.49 +*/
    1.50 +
    1.51 +var SECTION = "6-1";
    1.52 +var VERSION = "ECMA_1";
    1.53 +startTest();
    1.54 +var TITLE   = "Source Text";
    1.55 +
    1.56 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.57 +
    1.58 +var testcase = new TestCase( SECTION,
    1.59 +			     "// the following character should not be interpreted as a line terminator in a comment: \u000A",
    1.60 +			     'PASSED',
    1.61 +			     "PASSED" );
    1.62 +
    1.63 +// \u000A testcase.actual = "FAILED!";
    1.64 +
    1.65 +testcase =
    1.66 +  new TestCase( SECTION,
    1.67 +		"// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'",
    1.68 +		'PASSED',
    1.69 +		'PASSED' );
    1.70 +
    1.71 +// the following character should noy be interpreted as a line terminator: \\n testcase.actual = "FAILED"
    1.72 +
    1.73 +testcase =
    1.74 +  new TestCase( SECTION,
    1.75 +		"// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'",
    1.76 +		'PASSED',
    1.77 +		'PASSED' );
    1.78 +
    1.79 +// the following character should not be interpreted as a line terminator:   \u000A testcase.actual = "FAILED"
    1.80 +
    1.81 +testcase =
    1.82 +  new TestCase( SECTION,
    1.83 +		"// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'",
    1.84 +		'PASSED',
    1.85 +		'PASSED' );
    1.86 +// the following character should not be interpreted as a line terminator: \n testcase.actual = 'FAILED'
    1.87 +
    1.88 +testcase =
    1.89 +  new TestCase(   SECTION,
    1.90 +		  "// the following character should not be interpreted as a line terminator in a comment: u000D",
    1.91 +		  'PASSED',
    1.92 +		  'PASSED' );
    1.93 +
    1.94 +// the following character should not be interpreted as a line terminator:   \u000D testcase.actual = "FAILED"
    1.95 +
    1.96 +test();
    1.97 +

mercurial