mirror of https://github.com/tc39/test262.git
Add tests for ArrayBuffer.isView
This commit is contained in:
parent
35b93bb5c2
commit
887b379421
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false if arg has no [[ViewedArrayBuffer]] internal slot.
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
---*/
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView({}), false, "ordinary object");
|
||||
assert.sameValue(ArrayBuffer.isView([]), false, "Array");
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false from an instance of ArrayBuffer
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
---*/
|
||||
|
||||
var sample = new ArrayBuffer(1);
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(sample), false);
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false from DataView's instance `.buffer`
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [DataView]
|
||||
---*/
|
||||
|
||||
var sample = new DataView(new ArrayBuffer(1), 0, 0).buffer;
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(sample), false);
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false if arg is the DataView constructor
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [DataView]
|
||||
---*/
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(DataView), false, "DataView");
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return true if arg is an instance from a subclass of DataView
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [class, DataView]
|
||||
---*/
|
||||
|
||||
class DV extends DataView {}
|
||||
|
||||
var sample = new DV(new ArrayBuffer(1), 0, 0);
|
||||
|
||||
assert(ArrayBuffer.isView(sample));
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return true if is an instance of DataView
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [DataView]
|
||||
---*/
|
||||
|
||||
var sample = new DataView(new ArrayBuffer(1), 0, 0);
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(sample), true);
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false if arg is not Object
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(null), false, "null");
|
||||
assert.sameValue(ArrayBuffer.isView(undefined), false, "undefined");
|
||||
assert.sameValue(ArrayBuffer.isView(1), false, "number");
|
||||
assert.sameValue(ArrayBuffer.isView(""), false, "string");
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false from TypedArray's instance `.buffer`
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [TypedArray]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(ctor) {
|
||||
var sample = new ctor().buffer;
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(sample), false);
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false if arg is a TypedArray constructor
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [TypedArray]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(ctor) {
|
||||
assert.sameValue(ArrayBuffer.isView(ctor), false);
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return true if arg is an instance from a subclass of TypedArray
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [class, TypedArray]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(ctor) {
|
||||
class TA extends ctor {}
|
||||
|
||||
var sample = new TA();
|
||||
|
||||
assert(ArrayBuffer.isView(sample));
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return true if arg is an instance of TypedArray
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [TypedArray]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(ctor) {
|
||||
var sample = new ctor();
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(sample), true);
|
||||
});
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
`isView` can be invoked as a function
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [TypedArray, DataView]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
var isView = ArrayBuffer.isView;
|
||||
|
||||
testWithTypedArrayConstructors(function(ctor) {
|
||||
var sample = new ctor();
|
||||
assert.sameValue(isView(sample), true, "instance of TypedArray");
|
||||
});
|
||||
|
||||
var dv = new DataView(new ArrayBuffer(1), 0, 0);
|
||||
assert.sameValue(isView(dv), true, "instance of DataView");
|
||||
|
||||
assert.sameValue(isView(), false, "undefined arg");
|
||||
assert.sameValue(isView({}), false, "ordinary object");
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2016 The V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
Return false if isView is called with no arg
|
||||
info: >
|
||||
24.1.3.1 ArrayBuffer.isView ( arg )
|
||||
|
||||
1. If Type(arg) is not Object, return false.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.sameValue(ArrayBuffer.isView(), false);
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arraybuffer.isview
|
||||
description: >
|
||||
"isView" property of ArrayBuffer
|
||||
info: >
|
||||
ES6 section 17: Every other data property described in clauses 18 through 26
|
||||
and in Annex B.2 has the attributes { [[Writable]]: true,
|
||||
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
|
||||
includes: [propertyHelper.js, testTypedArray.js]
|
||||
---*/
|
||||
|
||||
verifyNotEnumerable(ArrayBuffer, "isView");
|
||||
verifyWritable(ArrayBuffer, "isView");
|
||||
verifyConfigurable(ArrayBuffer, "isView");
|
Loading…
Reference in New Issue