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.

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

mercurial