| Index: test/mjsunit/harmony/typedarrays.js
|
| diff --git a/test/mjsunit/harmony/typedarrays.js b/test/mjsunit/harmony/typedarrays.js
|
| index c6d130fc0c6dd30268e0a6ca3c2088bf16d2fbaa..1095345f61f49330a5b183a5ca932d4170ce5e15 100644
|
| --- a/test/mjsunit/harmony/typedarrays.js
|
| +++ b/test/mjsunit/harmony/typedarrays.js
|
| @@ -24,6 +24,8 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +//
|
| +// Flags: --allow-natives-syntax
|
|
|
| // ArrayBuffer
|
|
|
| @@ -559,7 +561,7 @@ for(i = 0; i < typedArrayConstructors.lenght; i++) {
|
| }
|
| TestEnumerable(DataView, new DataView(new ArrayBuffer()));
|
|
|
| -// Test arbitrary properties on ArrayBuffer
|
| +// Test arbitrary properties on ArrayBuffer and DataView
|
| function TestArbitrary(m) {
|
| function TestProperty(map, property, value) {
|
| map[property] = value;
|
| @@ -571,12 +573,50 @@ function TestArbitrary(m) {
|
| }
|
| }
|
| TestArbitrary(new ArrayBuffer(256));
|
| -for(i = 0; i < typedArrayConstructors.lenght; i++) {
|
| - TestArbitary(new typedArrayConstructors[i](10));
|
| -}
|
| TestArbitrary(new DataView(new ArrayBuffer(256)));
|
|
|
| +// Test arbitrary properties on TypedArrays
|
| +function TestArbitraryNonIndexed(m) {
|
| + function TestProperty(map, property, value) {
|
| + map[property] = value;
|
| + assertEquals(value, map[property]);
|
| + }
|
| + for (var i = 0; i < 20; i++) {
|
| + TestProperty(m, 'foo' + i, 'bar' + i);
|
| + }
|
| +}
|
| +for(i = 0; i < typedArrayConstructors.length; i++) {
|
| + TestArbitraryNonIndexed(new typedArrayConstructors[i](10));
|
| +}
|
| +
|
|
|
| // Test direct constructor call
|
| assertThrows(function() { ArrayBuffer(); }, TypeError);
|
| assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
|
| +
|
| +// Test that constructor can be called only on appropriate objects only once.
|
| +function TestConstructorBehavior(C) {
|
| + var obj = new C();
|
| + assertThrows(function() { C.call(obj); }, TypeError);
|
| + assertThrows(function() { C.call({}); }, TypeError);
|
| + var uninitObj = %NewObject(C);
|
| + C.call(uninitObj); // shouldn't throw
|
| +}
|
| +
|
| +TestConstructorBehavior(ArrayBuffer);
|
| +for(i = 0; i < typedArrayConstructors.length; i++) {
|
| + TestConstructorBehavior(typedArrayConstructors[i]);
|
| +}
|
| +
|
| +
|
| +// Test that DataView constructor can be called only on appropriate objects
|
| +// only once.
|
| +function TestDataViewConstructorBehavior() {
|
| + var ab = new ArrayBuffer(100);
|
| + var obj = new DataView(ab);
|
| + assertThrows(function() { DataView.call(obj, ab); }, TypeError);
|
| + assertThrows(function() { DataView.call({}, ab); }, TypeError);
|
| + var uninitObj = %NewObject(DataView);
|
| + DataView.call(uninitObj, ab); // shouldn't throw
|
| +}
|
| +TestDataViewConstructorBehavior();
|
|
|