~ubuntu-branches/ubuntu/vivid/mozjs24/vivid

« back to all changes in this revision

Viewing changes to js/src/tests/ecma_2/Statements/label-002.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/. */
 
5
 
 
6
 
 
7
/**
 
8
 *  File Name:          label-002.js
 
9
 *  ECMA Section:
 
10
 *  Description:        Labeled statements
 
11
 *
 
12
 *  Labeled break and continue within a for-in loop.
 
13
 *
 
14
 *
 
15
 *  Author:             christine@netscape.com
 
16
 *  Date:               11 August 1998
 
17
 */
 
18
var SECTION = "label-002";
 
19
var VERSION = "ECMA_2";
 
20
var TITLE   = "Labeled statements";
 
21
 
 
22
startTest();
 
23
writeHeaderToLog( SECTION + " "+ TITLE);
 
24
 
 
25
LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," );
 
26
LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" );
 
27
 
 
28
LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" );
 
29
LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" );
 
30
 
 
31
test();
 
32
 
 
33
function LabelTest( object, expect1, expect2 ) {
 
34
  result = "";
 
35
 
 
36
yoohoo:  { for ( property in object ) { result += object[property]; }; break yoohoo };
 
37
 
 
38
  new TestCase(
 
39
    SECTION,
 
40
    "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }",
 
41
    true,
 
42
    result == expect1 || result == expect2 );
 
43
}
 
44
 
 
45
function LabelTest2( object, expect1, expect2 ) {
 
46
  result = "";
 
47
 
 
48
yoohoo:  { for ( property in object ) { result += object[property]; break yoohoo } }; ;
 
49
 
 
50
  new TestCase(
 
51
    SECTION,
 
52
    "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}",
 
53
    true,
 
54
    result == expect1 || result == expect2 );
 
55
}
 
56