Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: test/mjsunit/es6/regexp-tostring.js

Issue 1679123007: [regexp] implement RegExp.prototype.toString for non-RegExp receiver. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/regexp.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var log = [];
6
7 var fake =
8 {
9 pattern: function() {
10 log.push("p");
11 return {
12 toString: function() {
13 log.push("ps");
14 return "pattern";
15 }
16 };
17 },
18 flags: function() {
19 log.push("f");
20 return {
21 toString: function() {
22 log.push("fs");
23 return "flags";
24 }
25 };
26 }
27 }
28
29 function testThrows(x) {
30 try {
31 RegExp.prototype.toString.call(x);
32 } catch (e) {
33 assertTrue(/incompatible receiver/.test(e.message));
34 return;
35 }
36 assertUnreachable();
37 }
38
39 testThrows(1);
40 testThrows(null);
41 Number.prototype.pattern = () => "a";
42 Number.prototype.flags = () => "b";
43 testThrows(1);
44
45 assertEquals("/pattern/flags", RegExp.prototype.toString.call(fake));
46 assertEquals(["p", "ps", "f", "fs"], log);
OLDNEW
« no previous file with comments | « src/js/regexp.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698