summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/NumberFormat/prototype/format/no-instanceof.js
blob: 03a4f7eac240cb4eff4908873837b8a361d14ee0 (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
// Copyright (C) 2021 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.numberformat.prototype.format
description: >
  Tests that Intl.NumberFormat.prototype.format calls
  OrdinaryHasInstance instead of the instanceof operator which includes a
  Symbol.hasInstance lookup and call among other things.
info: >
  UnwrapNumberFormat ( nf )

  2.  If nf does not have an [[InitializedNumberFormat]] internal slot and
      ? OrdinaryHasInstance(%NumberFormat%, nf) is true, then
      a.  Return ? Get(nf, %Intl%.[[FallbackSymbol]]).
---*/

const nf = Object.create(Intl.NumberFormat.prototype);

Object.defineProperty(Intl.NumberFormat, Symbol.hasInstance, {
    get() { throw new Test262Error(); }
});

assert.throws(TypeError, () => nf.format);

reportCompare(0, 0);