michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cr = Components.results; michael@0: michael@0: function test_formatdatetime_return() michael@0: { michael@0: var dateConv = Cc["@mozilla.org/intl/scriptabledateformat;1"]. michael@0: getService(Ci.nsIScriptableDateFormat); michael@0: michael@0: /* Testing if we throw instead of crashing when we are passed 0s. */ michael@0: var x = false; michael@0: try { michael@0: dateConv.FormatDate("", Ci.nsIScriptableDateFormat.dateFormatLong, michael@0: 0, 0, 0); michael@0: } michael@0: catch (e if (e.result == Cr.NS_ERROR_INVALID_ARG)) { michael@0: x = true; michael@0: } michael@0: if (!x) michael@0: do_throw("FormatDate didn't throw when passed 0 for its arguments."); michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: test_formatdatetime_return(); michael@0: }