Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1684)

Unified Diff: tests/assert.js

Issue 6591072: Implementing String, Number and Date toLocaleXXXString overrides as per ECMA 402, Chapter 13. Small… (Closed) Base URL: http://v8-i18n.googlecode.com/svn/trunk/
Patch Set: Fixed indentation in overrides.js. Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/overrides.js ('k') | tests/intl/overrides/date.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/assert.js
===================================================================
--- tests/assert.js (revision 150)
+++ tests/assert.js (working copy)
@@ -113,6 +113,48 @@
/**
+ * Returns true if code throws specified exception.
+ */
+function assertThrows(code, type_opt, cause_opt) {
+ var threwException = true;
+ try {
+ if (typeof code == 'function') {
+ code();
+ } else {
+ eval(code);
+ }
+ threwException = false;
+ } catch (e) {
+ if (typeof type_opt == 'function') {
+ assertInstanceof(e, type_opt);
+ }
+ if (arguments.length >= 3) {
+ assertEquals(e.type, cause_opt);
+ }
+ // Success.
+ return;
+ }
+ throw new Error("Did not throw exception");
+}
+
+
+/**
+ * Throws an exception if code throws.
+ */
+function assertDoesNotThrow(code, name_opt) {
+ try {
+ if (typeof code == 'function') {
+ code();
+ } else {
+ eval(code);
+ }
+ } catch (e) {
+ fail("threw an exception: ", e.message || e, name_opt);
+ }
+}
+
+
+/**
* Throws if obj is not of given type.
*/
function assertInstanceof(obj, type) {
« no previous file with comments | « src/overrides.js ('k') | tests/intl/overrides/date.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b