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

Unified Diff: test/mjsunit/stack-traces-custom-lazy.js

Issue 20692002: Lazy call to custom stack trace formatting using Error.prepareStackTrace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: adapting one test Created 7 years, 5 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 | « test/mjsunit/stack-traces.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/stack-traces-custom-lazy.js
diff --git a/test/intl/date-format/format-test.js b/test/mjsunit/stack-traces-custom-lazy.js
similarity index 76%
copy from test/intl/date-format/format-test.js
copy to test/mjsunit/stack-traces-custom-lazy.js
index 9817c97ed975283f2313e7b1ece8a0b110365e84..91d97f3739dc746434731352a0ec7ade0d839484 100644
--- a/test/intl/date-format/format-test.js
+++ b/test/mjsunit/stack-traces-custom-lazy.js
@@ -25,22 +25,25 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Test formatting method with specified date, invalid input.
-
-var dtf = new Intl.DateTimeFormat('en-US', {timeZone: 'UTC'});
-
-var someDate = dtf.format(144313200000);
-assertEquals('7/29/1974', someDate);
-
-var invalidValues = [NaN, Infinity, -Infinity];
-invalidValues.forEach(function(value) {
- var error;
+function testPrepareStackTrace(closure) {
+ var error = undefined;
try {
- dtf.format(value);
+ closure();
+ assertUnreachable();
} catch (e) {
error = e;
}
- assertTrue(error !== undefined);
- assertEquals('RangeError', error.name);
-});
+ // We expect custom formatting to be lazy. Setting the custom
+ // function right before calling error.stack should be fine.
+ Error.prepareStackTrace = function(e, frames) {
+ return "bar";
+ }
+
+ assertEquals("bar", error.stack);
+ Error.prepareStackTrace = undefined;
+}
+
+testPrepareStackTrace(function() { throw new Error("foo"); });
+testPrepareStackTrace(function f() { f(); });
+
« no previous file with comments | « test/mjsunit/stack-traces.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698