Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 24.1.2
5 description: Subclassing the ArrayBuffer object
6 info: |
7 24.1.2 The ArrayBuffer Constructor
8
9 ...
10
11 The ArrayBuffer constructor is designed to be subclassable. It may be used as
12 the value of an extends clause of a class definition. Subclass constructors
13 that intend to inherit the specified ArrayBuffer behaviour must include a
14 super call to the ArrayBuffer constructor to create and initialize subclass
15 instances with the internal state necessary to support the
16 ArrayBuffer.prototype built-in methods.
17 ---*/
18
19 class AB extends ArrayBuffer {}
20
21 var ab = new AB(4);
22
23 var sliced = ab.slice(0, 1);
24
25 assert(sliced instanceof AB);
26 assert(sliced instanceof ArrayBuffer);
27
28 reportCompare(0, 0);