summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-dotall.js
blob: 7b6afe6f548df24da39c39dd600947d4dbc6a5b3 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2017 Aleksey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-regexp.prototype.flags
description: Boolean coercion of the dotAll property
info: |
  get RegExp.prototype.flags

  ...
  10. Let dotAll be ToBoolean(? Get(R, "dotAll")).
  ...
features: [Symbol, regexp-dotall]
---*/

var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get;

var r = {};

r.dotAll = undefined;
assert.sameValue(get.call(r), "", "dotAll: undefined");

r.dotAll = null;
assert.sameValue(get.call(r), "", "dotAll: null");

r.dotAll = NaN;
assert.sameValue(get.call(r), "", "dotAll: NaN");

r.dotAll = "";
assert.sameValue(get.call(r), "", "dotAll: the empty string");

r.dotAll = "string";
assert.sameValue(get.call(r), "s", "dotAll: string");

r.dotAll = 86;
assert.sameValue(get.call(r), "s", "dotAll: 86");

r.dotAll = Symbol();
assert.sameValue(get.call(r), "s", "dotAll: Symbol()");

r.dotAll = [];
assert.sameValue(get.call(r), "s", "dotAll: []");

r.dotAll = {};
assert.sameValue(get.call(r), "s", "dotAll: {}");

reportCompare(0, 0);