OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8603 double stored_date = date->NumberValue(); | 8603 double stored_date = date->NumberValue(); |
8604 if (!IsNaN(expected_stored_date)) { | 8604 if (!IsNaN(expected_stored_date)) { |
8605 CHECK_EQ(expected_stored_date, stored_date); | 8605 CHECK_EQ(expected_stored_date, stored_date); |
8606 } else { | 8606 } else { |
8607 uint64_t stored_bits = DoubleToBits(stored_date); | 8607 uint64_t stored_bits = DoubleToBits(stored_date); |
8608 // Check if quiet nan (bits 51..62 all set). | 8608 // Check if quiet nan (bits 51..62 all set). |
8609 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 8609 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
8610 } | 8610 } |
8611 } | 8611 } |
8612 } | 8612 } |
| 8613 |
| 8614 |
| 8615 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) { |
| 8616 v8::HandleScope scope; |
| 8617 v8::TryCatch tc; |
| 8618 v8::Handle<v8::String> str = args[0]->ToString(); |
| 8619 if (tc.HasCaught()) |
| 8620 return tc.ReThrow(); |
| 8621 return v8::Undefined(); |
| 8622 } |
| 8623 |
| 8624 |
| 8625 // Test that an exception can be propagated down through a spaghetti |
| 8626 // stack using ReThrow. |
| 8627 THREADED_TEST(SpaghettiStackReThrow) { |
| 8628 v8::HandleScope scope; |
| 8629 LocalContext context; |
| 8630 context->Global()->Set( |
| 8631 v8::String::New("s"), |
| 8632 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); |
| 8633 v8::TryCatch try_catch; |
| 8634 CompileRun( |
| 8635 "var i = 0;" |
| 8636 "var o = {" |
| 8637 " toString: function () {" |
| 8638 " if (i == 10) {" |
| 8639 " throw 'Hey!';" |
| 8640 " } else {" |
| 8641 " i++;" |
| 8642 " return s(o);" |
| 8643 " }" |
| 8644 " }" |
| 8645 "};" |
| 8646 "s(o);"); |
| 8647 CHECK(try_catch.HasCaught()); |
| 8648 v8::String::Utf8Value value(try_catch.Exception()); |
| 8649 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8650 } |
OLD | NEW |