js/src/tests/ecma_5/strict/11.1.5.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
michael@0 3 /*
michael@0 4 * Any copyright is dedicated to the Public Domain.
michael@0 5 * http://creativecommons.org/licenses/publicdomain/
michael@0 6 */
michael@0 7
michael@0 8 /* Simple identifier labels. */
michael@0 9 assertEq(testLenientAndStrict('({x:1, x:1})',
michael@0 10 parsesSuccessfully,
michael@0 11 parseRaisesException(SyntaxError)),
michael@0 12 true);
michael@0 13
michael@0 14 assertEq(testLenientAndStrict('({x:1, y:1})',
michael@0 15 parsesSuccessfully,
michael@0 16 parsesSuccessfully),
michael@0 17 true);
michael@0 18
michael@0 19 assertEq(testLenientAndStrict('({x:1, y:1, x:1})',
michael@0 20 parsesSuccessfully,
michael@0 21 parseRaisesException(SyntaxError)),
michael@0 22 true);
michael@0 23
michael@0 24 /* Property names can be written as strings, too. */
michael@0 25 assertEq(testLenientAndStrict('({x:1, "x":1})',
michael@0 26 parsesSuccessfully,
michael@0 27 parseRaisesException(SyntaxError)),
michael@0 28 true);
michael@0 29
michael@0 30 assertEq(testLenientAndStrict('({"x":1, x:1})',
michael@0 31 parsesSuccessfully,
michael@0 32 parseRaisesException(SyntaxError)),
michael@0 33 true);
michael@0 34
michael@0 35 assertEq(testLenientAndStrict('({"x":1, "x":1})',
michael@0 36 parsesSuccessfully,
michael@0 37 parseRaisesException(SyntaxError)),
michael@0 38 true);
michael@0 39
michael@0 40 /* Numeric property names. */
michael@0 41 assertEq(testLenientAndStrict('({1.5:1, 1.5:1})',
michael@0 42 parsesSuccessfully,
michael@0 43 parseRaisesException(SyntaxError)),
michael@0 44 true);
michael@0 45
michael@0 46 assertEq(testLenientAndStrict('({1.5:1, 15e-1:1})',
michael@0 47 parsesSuccessfully,
michael@0 48 parseRaisesException(SyntaxError)),
michael@0 49 true);
michael@0 50
michael@0 51 assertEq(testLenientAndStrict('({6.02214179e23:1, 6.02214179e23:1})',
michael@0 52 parsesSuccessfully,
michael@0 53 parseRaisesException(SyntaxError)),
michael@0 54 true);
michael@0 55
michael@0 56 assertEq(testLenientAndStrict('({6.02214179e23:1, 3.1415926535:1})',
michael@0 57 parsesSuccessfully,
michael@0 58 parsesSuccessfully),
michael@0 59 true);
michael@0 60
michael@0 61 assertEq(testLenientAndStrict('({ 1: 1, "1": 2 })',
michael@0 62 parsesSuccessfully,
michael@0 63 parseRaisesException(SyntaxError)),
michael@0 64 true);
michael@0 65
michael@0 66 assertEq(testLenientAndStrict('({ "1": 1, 1: 2 })',
michael@0 67 parsesSuccessfully,
michael@0 68 parseRaisesException(SyntaxError)),
michael@0 69 true);
michael@0 70
michael@0 71 assertEq(testLenientAndStrict('({ 2.5: 1, "2.5": 2 })',
michael@0 72 parsesSuccessfully,
michael@0 73 parseRaisesException(SyntaxError)),
michael@0 74 true);
michael@0 75
michael@0 76 assertEq(testLenientAndStrict('({ "2.5": 1, 2.5: 2 })',
michael@0 77 parsesSuccessfully,
michael@0 78 parseRaisesException(SyntaxError)),
michael@0 79 true);
michael@0 80
michael@0 81 /* Many properties, to exercise JSAtomList's hash-table variant. */
michael@0 82 assertEq(testLenientAndStrict('({a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1, q:1, r:1, s:1, t:1, u:1, v:1, w:1, x:1, y:1, z:1})',
michael@0 83 parsesSuccessfully,
michael@0 84 parsesSuccessfully),
michael@0 85 true);
michael@0 86
michael@0 87 assertEq(testLenientAndStrict('({a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1, q:1, r:1, s:1, t:1, u:1, v:1, w:1, x:1, y:1, a:1})',
michael@0 88 parsesSuccessfully,
michael@0 89 parseRaisesException(SyntaxError)),
michael@0 90 true);
michael@0 91
michael@0 92 /*
michael@0 93 * Getters, setters, and value properties should conflict only when
michael@0 94 * appropriate.
michael@0 95 */
michael@0 96 assertEq(testLenientAndStrict('({get x() {}, x:1})',
michael@0 97 parseRaisesException(SyntaxError),
michael@0 98 parseRaisesException(SyntaxError)),
michael@0 99 true);
michael@0 100
michael@0 101 assertEq(testLenientAndStrict('({x:1, get x() {}})',
michael@0 102 parseRaisesException(SyntaxError),
michael@0 103 parseRaisesException(SyntaxError)),
michael@0 104 true);
michael@0 105
michael@0 106 assertEq(testLenientAndStrict('({set x(q) {}, x:1})',
michael@0 107 parseRaisesException(SyntaxError),
michael@0 108 parseRaisesException(SyntaxError)),
michael@0 109 true);
michael@0 110
michael@0 111 assertEq(testLenientAndStrict('({x:1, set x(q) {}})',
michael@0 112 parseRaisesException(SyntaxError),
michael@0 113 parseRaisesException(SyntaxError)),
michael@0 114 true);
michael@0 115
michael@0 116 assertEq(testLenientAndStrict('({1:1, set 1(q) {}})',
michael@0 117 parseRaisesException(SyntaxError),
michael@0 118 parseRaisesException(SyntaxError)),
michael@0 119 true);
michael@0 120
michael@0 121 assertEq(testLenientAndStrict('({set 1(q) {}, 1:1})',
michael@0 122 parseRaisesException(SyntaxError),
michael@0 123 parseRaisesException(SyntaxError)),
michael@0 124 true);
michael@0 125
michael@0 126 assertEq(testLenientAndStrict('({"1":1, set 1(q) {}})',
michael@0 127 parseRaisesException(SyntaxError),
michael@0 128 parseRaisesException(SyntaxError)),
michael@0 129 true);
michael@0 130
michael@0 131 assertEq(testLenientAndStrict('({set 1(q) {}, "1":1})',
michael@0 132 parseRaisesException(SyntaxError),
michael@0 133 parseRaisesException(SyntaxError)),
michael@0 134 true);
michael@0 135
michael@0 136 assertEq(testLenientAndStrict('({get x() {}, set x(q) {}})',
michael@0 137 parsesSuccessfully,
michael@0 138 parsesSuccessfully),
michael@0 139 true);
michael@0 140
michael@0 141 assertEq(testLenientAndStrict('({set x(q) {}, get x() {}})',
michael@0 142 parsesSuccessfully,
michael@0 143 parsesSuccessfully),
michael@0 144 true);
michael@0 145
michael@0 146 assertEq(testLenientAndStrict('({get x() {}, set x(q) {}, x:1})',
michael@0 147 parseRaisesException(SyntaxError),
michael@0 148 parseRaisesException(SyntaxError)),
michael@0 149 true);
michael@0 150
michael@0 151 assertEq(testLenientAndStrict('({set x(q) {}, get x() {}, x:1})',
michael@0 152 parseRaisesException(SyntaxError),
michael@0 153 parseRaisesException(SyntaxError)),
michael@0 154 true);
michael@0 155
michael@0 156 assertEq(testLenientAndStrict('({get x() {}, get x() {}})',
michael@0 157 parseRaisesException(SyntaxError),
michael@0 158 parseRaisesException(SyntaxError)),
michael@0 159 true);
michael@0 160
michael@0 161 assertEq(testLenientAndStrict('({set x() {}, set x() {}})',
michael@0 162 parseRaisesException(SyntaxError),
michael@0 163 parseRaisesException(SyntaxError)),
michael@0 164 true);
michael@0 165
michael@0 166 assertEq(testLenientAndStrict('({get x() {}, set x(q) {}, y:1})',
michael@0 167 parsesSuccessfully,
michael@0 168 parsesSuccessfully),
michael@0 169 true);
michael@0 170
michael@0 171 reportCompare(true, true);

mercurial