js/src/tests/test262/ch12/12.2/S12.2_A1.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 // Copyright 2009 the Sputnik authors.  All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * Variables are created when the program is entered. Variables are initialised to "undefined"
     6  * when created. A variable with an Initialiser is assigned the value of its AssignmentExpression when the
     7  * VariableStatement is executed, not when the variable is created
     8  *
     9  * @path ch12/12.2/S12.2_A1.js
    10  * @description Creating variables after entering the execution scope
    11  */
    13 //////////////////////////////////////////////////////////////////////////////
    14 //CHECK#1
    15 try {
    16 	__x = __x;
    17     __y = __x ? "good fellow" : "liar"; // __y assigned to "liar" since __x undefined
    18     __z = __z === __x ? 1 : 0; // __z assigned to 1 since both __x and __z are undefined
    19 } catch (e) {
    20 	$ERROR('#1: Using declarated variable before it declaration is admitted');
    21 }
    22 //
    23 //////////////////////////////////////////////////////////////////////////////
    25 //////////////////////////////////////////////////////////////////////////////
    26 //CHECK#2
    27 try{
    28     __something__undefined = __something__undefined;
    29     $ERROR('#2: "__something__undefined = __something__undefined" lead to throwing exception');
    30 } catch(e){
    31     $PRINT(e.message);
    32 }
    33 //
    34 //////////////////////////////////////////////////////////////////////////////
    36 //////////////////////////////////////////////////////////////////////////////
    37 //CHECK#3
    38 if ((__y !== "liar")&(__z !== 1)) {
    39 	$ERROR('#3: (__y === "liar") and (__z === 1). Actual:  __y ==='+__y+' and __z ==='+__z  );
    40 }
    41 //
    42 //////////////////////////////////////////////////////////////////////////////
    44 var __x, __y = true, __z = __y ? "smeagol" : "golum";
    46 //////////////////////////////////////////////////////////////////////////////
    47 //CHECK#4
    48 if (!__y&!(__z = "smeagol")) {
    49 	$ERROR('#4: A variable with an Initialiser is assigned the value of its AssignmentExpression when the VariableStatement is executed');
    50 }
    51 //
    52 //////////////////////////////////////////////////////////////////////////////

mercurial