|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 |
|
3 /* |
|
4 * Any copyright is dedicated to the Public Domain. |
|
5 * http://creativecommons.org/licenses/publicdomain/ |
|
6 */ |
|
7 |
|
8 function arr() { |
|
9 return Object.defineProperty([20, 10, 30], 0, {writable: false}); |
|
10 } |
|
11 |
|
12 assertEq(testLenientAndStrict('var a = arr(); a.sort()', |
|
13 raisesException(TypeError), |
|
14 raisesException(TypeError)), |
|
15 true); |
|
16 |
|
17 function obj() { |
|
18 var o = {0: 20, 1: 10, 2: 30, length: 3}; |
|
19 Object.defineProperty(o, 0, {writable: false}); |
|
20 return o; |
|
21 } |
|
22 |
|
23 assertEq(testLenientAndStrict('var o = obj(); Array.prototype.sort.call(o)', |
|
24 raisesException(TypeError), |
|
25 raisesException(TypeError)), |
|
26 true); |
|
27 |
|
28 // The behavior of sort is implementation-defined if the object being |
|
29 // sorted is sparse, so I'm not sure how to test its behavior on |
|
30 // non-configurable properties. |
|
31 |
|
32 reportCompare(true, true); |