summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-subclass-instance.js
blob: 66f6e3f5a67735e1c263b97644e235d5a16f1316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// |reftest| skip -- legacy-regexp is not supported
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-regexp.prototype.compile
description: RegExp.prototype.compile throws a TypeError for calls on subclasses
features: [legacy-regexp,class]
---*/

const subclass_regexp = new (class extends RegExp {})("");

assert.throws(
  TypeError,
  function () {
    subclass_regexp.compile();
  },
  "`subclass_regexp.compile()` throws TypeError"
);

assert.throws(
  TypeError,
  function () {
    RegExp.prototype.compile.call(subclass_regexp);
  },
  "`RegExp.prototype.compile.call(subclass_regexp)` throws TypeError"
);

reportCompare(0, 0);