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

Unified Diff: test/intl/bad-target.js

Issue 2600913002: [intl] Remove redundant type checking system (Closed)
Patch Set: 80col limit Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | test/mjsunit/regress/regress-4962.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/intl/bad-target.js
diff --git a/test/intl/bad-target.js b/test/intl/bad-target.js
new file mode 100644
index 0000000000000000000000000000000000000000..7b7cbe9b5dd24268fadaa509af78cc1cc935b7e1
--- /dev/null
+++ b/test/intl/bad-target.js
@@ -0,0 +1,39 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Calling Intl methods with a bad receiver throws a TypeError
+
+// An uninitialized object of the same type
+assertThrows(() => Object.create(Intl.DateTimeFormat.prototype).format(),
+ TypeError);
+assertThrows(() => Object.create(Intl.NumberFormat.prototype).format(),
+ TypeError);
+assertThrows(() => Object.create(Intl.Collator.prototype).compare(),
+ TypeError);
+assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).adoptText(),
+ TypeError);
+assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).first(),
+ TypeError);
+assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).next(),
+ TypeError);
+assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).current(),
+ TypeError);
+assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).breakType(),
+ TypeError);
+
+// Or similarly, just accessing the method getter on the prototype
+assertThrows(() => Intl.DateTimeFormat.prototype.format, TypeError);
+assertThrows(() => Intl.NumberFormat.prototype.format, TypeError);
+assertThrows(() => Intl.Collator.prototype.compare, TypeError);
+assertThrows(() => Intl.v8BreakIterator.prototype.adoptText, TypeError);
+assertThrows(() => Intl.v8BreakIterator.prototype.first, TypeError);
+assertThrows(() => Intl.v8BreakIterator.prototype.next, TypeError);
+assertThrows(() => Intl.v8BreakIterator.prototype.current, TypeError);
+assertThrows(() => Intl.v8BreakIterator.prototype.breakType, TypeError);
+
+// The method .call'd on a different instance will have that
+// other instance benignly ignored, since it's a bound function
+let nf = Intl.NumberFormat();
+let df = Intl.DateTimeFormat();
+assertEquals("0", nf.format.call(df, 0));
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | test/mjsunit/regress/regress-4962.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698