Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / e4x / extensions / regress-335051.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * Any copyright is dedicated to the Public Domain.
4  * http://creativecommons.org/licenses/publicdomain/
5  * Contributor:
6  *   rje(a)dbc.dk
7  */
8
9 //-----------------------------------------------------------------------------
10 var BUGNUMBER = 335051;
11 var summary = '';
12 var actual = '';
13 var expect = '';
14
15
16 //-----------------------------------------------------------------------------
17 test();
18 //-----------------------------------------------------------------------------
19 function testSyntax(syntax, isValid) {
20   var result;
21   try {
22     eval(syntax);
23     result = true;
24   } catch(exception) {
25     if (SyntaxError.prototype.isPrototypeOf(exception)) {
26       result = false;
27     }
28   }
29   reportCompare(isValid, result, "test " + (isValid?"":"in") + "valid syntax: " + syntax);
30 }
31
32 function test()
33 {
34   enterFunc ('test');
35   printBugNumber(BUGNUMBER);
36   printStatus (summary);
37   var oldVersion = false;
38
39   testSyntax("#1={}", true);
40   testSyntax("#1=[]", true);
41   testSyntax("#1=([])", true);
42
43   testSyntax("#1=[1, 2, 3]", true);
44   testSyntax("#1={a:1, b:2}", true);
45
46   testSyntax("#1=function() { }", true);
47   testSyntax("#1=(new Date())", true);
48
49   testSyntax("#1=<a/>", true);
50   testSyntax("#1=<!-- -->", true);
51   testSyntax("#1=<a>b</a>", true);
52   testSyntax("[#1=<a>b</a>, #1#]", true);
53   testSyntax("#1=(<a/>)", true);
54   testSyntax("#1=(<![CDATA[foo]]>)", true);
55
56   testSyntax("#1=123", false);
57   testSyntax("#1='foo'", false);
58   testSyntax("#1=1+2", false);
59   testSyntax("#1=-1", false);
60   testSyntax("#1=(123)", false);
61   testSyntax("#1=true", false);
62
63   exitFunc ('test');
64 }