summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-sticky.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-sticky.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-sticky.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-sticky.js b/js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-sticky.js
new file mode 100644
index 0000000000..6ebd0cf5e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/flags/coercion-sticky.js
@@ -0,0 +1,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 sticky property
+info: |
+ get RegExp.prototype.flags
+
+ ...
+ 14. Let sticky be ToBoolean(? Get(R, "sticky")).
+ ...
+features: [Symbol]
+---*/
+
+var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get;
+
+var r = {};
+
+r.sticky = undefined;
+assert.sameValue(get.call(r), "", "sticky: undefined");
+
+r.sticky = null;
+assert.sameValue(get.call(r), "", "sticky: null");
+
+r.sticky = NaN;
+assert.sameValue(get.call(r), "", "sticky: NaN");
+
+r.sticky = "";
+assert.sameValue(get.call(r), "", "sticky: the empty string");
+
+r.sticky = "string";
+assert.sameValue(get.call(r), "y", "sticky: string");
+
+r.sticky = 86;
+assert.sameValue(get.call(r), "y", "sticky: 86");
+
+r.sticky = Symbol();
+assert.sameValue(get.call(r), "y", "sticky: Symbol()");
+
+r.sticky = [];
+assert.sameValue(get.call(r), "y", "sticky: []");
+
+r.sticky = {};
+assert.sameValue(get.call(r), "y", "sticky: {}");
+
+reportCompare(0, 0);