Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/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: 19.5.1
5 description: Subclassing the Error object
6 info: |
7 19.5.1 The Error Constructor
8
9 ...
10 The Error constructor is designed to be subclassable. It may be used as the
11 alue of an extends clause of a class definition. Subclass constructors that
12 intend to inherit the specified Error behaviour must include a super call to
13 the Error constructor to create and initialize subclass instances with a
14 [[ErrorData]] internal slot.
15 ---*/
16
17 class CustomError extends Error {}
18
19 var err = new CustomError('foo 42');
20
21 assert.sameValue(err.message, 'foo 42');
22 assert.sameValue(err.name, 'Error');
23
24 reportCompare(0, 0);